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

Multipage pdf with statement #2416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 18, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
multipage pdf: show usage of with statement in example
  • Loading branch information
megies committed Sep 12, 2013
commit 8b69b80a1113e92e3788dd630e6a2add93674d6d
17 changes: 17 additions & 0 deletions 17 examples/pylab_examples/multipage_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,20 @@

# Remember to close the object - otherwise the file will not be usable
pdf.close()

# Or use the with statement, the file gets properly closed at the end:
with PdfPages('multipage_pdf2.pdf') as pdf:

figure(figsize=(3, 3))
plot(range(7), [3, 1, 4, 1, 5, 9, 2], 'r-o')
title('Page One')
pdf.savefig()
close()

rc('text', usetex=True)
figure(figsize=(8, 6))
x = np.arange(0, 5, 0.1)
plot(x, np.sin(x), 'b-')
title('Page Two')
pdf.savefig()
close()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.