Skip to content

Correctly set temporary pdf/pgf backends #27869

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
Mar 6, 2024

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Mar 6, 2024

PR summary

Calling FigureCanvasPdf(figure) will call figure.set_canvas(self), meaning the cbook._setattr_cm context manager that wraps this change will see the new canvas, and the old canvas isn't restored.

Instead, just pass the backend parameter, as savefig already knows how to correctly save and restore the canvas if it needs to change backends.

Fixes #27865

PR checklist

Calling `FigureCanvasPdf(figure)` will call `figure.set_canvas(self)`,
meaning the `cbook._setattr_cm` context manager that wraps this change
will see the _new_ canvas, and the old canvas isn't restored.

Instead, just pass the `backend` parameter, as `savefig` already knows
how to correctly save and restore the canvas if it needs to change
backends.

Fixes matplotlib#27865
@Impaler343
Copy link
Contributor

Hey, could you commit the documentation change that I mentioned earlier in the issue #27865 as well?

@timhoffm
Copy link
Member

timhoffm commented Mar 6, 2024

I’m merging as is. Adding the doc fix here or creating a separate PR for it is an equal amount of work. So, let’s already take this.

@timhoffm timhoffm merged commit 87d1da1 into matplotlib:main Mar 6, 2024
@tacaswell tacaswell added this to the v3.9.0 milestone Mar 6, 2024
@QuLogic QuLogic deleted the fix-pdf-pgf-backend branch March 6, 2024 20:44
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.

[Bug]: Zoom und pan not working after writing pdf pages.
5 participants