8000 show only preferred usage for PdfPages and use preferred pyplot import · matplotlib/matplotlib@c60dfdd · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c60dfdd

Browse files
committed
show only preferred usage for PdfPages and use preferred pyplot import
style
1 parent 303477a commit c60dfdd

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

examples/pylab_examples/multipage_pdf.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,39 @@
22

33
import datetime
44
import numpy as np
5-
import matplotlib
65
from matplotlib.backends.backend_pdf import PdfPages
7-
from pylab import *
6+
import matplotlib.pyplot as plt
87

98
# Create the PdfPages object to which we will save the pages:
109
# The with statement makes sure that the PdfPages object is closed properly at
1110
# the end of the block, even if an Exception occurs.
1211
with PdfPages('multipage_pdf.pdf') as pdf:
13-
figure(figsize=(3,3))
14-
plot(range(7), [3,1,4,1,5,9,2], 'r-o')
15-
title('Page One')
12+
plt.figure(figsize=(3, 3))
13+
plt.plot(range(7), [3, 1, 4, 1, 5, 9, 2], 'r-o')
14+
plt.title('Page One')
1615
pdf.savefig() # saves the current figure into a pdf page
17-
close()
16+
plt.close()
1817

19-
rc('text', usetex=True)
20-
figure(figsize=(8,6))
21-
x = np.arange(0,5,0.1)
22-
plot(x, np.sin(x), 'b-')
23-
title('Page Two')
18+
plt.rc('text', usetex=True)
19+
plt.figure(figsize=(8, 6))
20+
x = np.arange(0, 5, 0.1)
21+
plt.plot(x, np.sin(x), 'b-')
22+
plt.title('Page Two')
2423
pdf.savefig()
25-
close()
24+
plt.close()
2625

27-
rc('text', usetex=False)
28-
fig=figure(figsize=(4,5))
29-
plot(x, x*x, 'ko')
30-
title('Page Three')
31-
pdf.savefig(fig) # or you can pass a Figure object to pdf.savefig
32-
close()
26+
plt.rc('text', usetex=False)
27+
fig = plt.figure(figsize=(4, 5))
28+
plt.plot(x, x*x, 'ko')
29+
plt.title('Page Three')
30+
pdf.savefig(fig) # or you can pass a Figure object to pdf.savefig
31+
plt.close()
3332

3433
# We can also set the file's metadata via the PdfPages object:
3534
d = pdf.infodict()
3635
d['Title'] = 'Multipage PDF Example'
3736
d['Author'] = u'Jouni K. Sepp\xe4nen'
3837
d['Subject'] = 'How to create a multipage pdf file and set its metadata'
3938
d['Keywords'] = 'PdfPages multipage keywords author title subject'
40-
d['CreationDate'] = datetime.datetime(2009,11,13)
39+
d['CreationDate'] = datetime.datetime(2009, 11, 13)
4140
d['ModDate'] = datetime.datetime.today()

0 commit comments

Comments
 (0)
0