-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: pass renderer through adjust_bbox #29340
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
Conversation
@@ -2169,7 +2172,7 @@ def print_figure( | |||
|
|||
# call adjust_bbox to save only the given area | |||
restore_bbox = _tight_bbox.adjust_bbox( | |||
self.figure, bbox_inches, self.figure.canvas.fixed_dpi) | |||
self.figure, bbox_inches, renderer, self.figure.canvas.fixed_dpi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing the renderer here does not affect the target issue but I assume that passing it when we have it is more efficient than potentially calling _get_renderer
again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test we can do with the main library, or are the effects too subtle there?
We need an axes that uses a locator that requires a renderer. Do we have one of those in the main library? I checked that Also I should have mentioned that this change does nothing for your example at #27763 (comment) (although that one also looks fine if you bump the dpi to 300). |
OK< so there is still a small registration issue. Thanks for checking. |
|
PR summary
Closes #27763.
I have not fully understood what was going wrong, but I did discover that when fig._get_renderer is called,
fig.dpi
gets reset to 72. As the renderer had deliberately set it to something else here, this is probably not helpful! Anyway, it is intuitive to me that the renderer used to work out where things are should be the same renderer that does this part of the drawing. Taking a simplified version of the #27763 example,With main:

With my branch:

The alignment is still not perfect (as also shown in the new test image), but it looks identical to what I get with v3.7.1 (before I started breaking things 🐑). I note that several commenters on the issue seemed happy with v3.7.1 behaviour. Also I cannot see any offset if I increase the dpi to 300:
I propose to open a new issue to track the remaining small offset.
PR checklist