Skip to content

Fix PdfPages+cairo. #9114

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 1 commit into from
Feb 11, 2018
Merged

Fix PdfPages+cairo. #9114

merged 1 commit into from
Feb 11, 2018

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Aug 28, 2017

... by forcing pdf backend output from within PdfPages.

Fixes #9112. No tests because the only realistic use case is with cairo, which is not tested either (but #9112 is fixed when manually trying it).

Attn @OceanWolf

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@tacaswell tacaswell added this to the 2.2 (next next feature release) milestone Aug 29, 2017
@anntzer anntzer force-pushed the pdfpages-cairo branch 2 times, most recently from 697f479 to 170d569 Compare August 29, 2017 09:00
... by forcing pdf backend output from within PdfPages.
try:
orig_canvas = figure.canvas
figure.canvas = FigureCanvasPdf(figure)
figure.savefig(self, format="pdf", **kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we were already using the pdf backend? How much extra work would this create? Does the new canvas need to get explicitly destroyed to free memory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating the FigureCanvasPdf is really cheap (it is defined just below -- its init is directly inherited from FigureCanvasBase, which doesn't do anything fancy either).
The temporary canvas will get GC'd per normal python semantics.

@tacaswell tacaswell merged commit 206b5fe into matplotlib:master Feb 11, 2018
@anntzer anntzer deleted the pdfpages-cairo branch February 12, 2018 05:09
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PDFPages Errors on savefig (missing encode)
4 participants