Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jklymak merged 1 commit intomatplotlib:mainfromrcomer:inset_axes-renderer
Dec 18, 2024

Conversation

rcomer
Copy link
Member

@rcomerrcomer commentedDec 17, 2024
edited
Loading

PR summary

Closes#27763.

I have not fully understood what was going wrong, but I did discover that whenfig._get_renderer is called,fig.dpi gets reset to 72. As the renderer had deliberately set it to something elsehere, 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,

frommpl_toolkits.axes_grid1.inset_locatorimportinset_axesimportmatplotlib.pyplotaspltimportnumpyasnpfig,axes=plt.subplots(1,1,dpi=100)x=np.random.randint(100,size=(10,200))c=axes.imshow(x,origin='lower',cmap='Reds',aspect='auto')axins1=inset_axes(axes,width="10%",height="30%",loc="upper left",bbox_to_anchor= (0.045,0.,1,1),bbox_transform=axes.transAxes                    )fig.colorbar(c,cax=axins1,orientation="horizontal")fig.savefig('test_single.pdf',bbox_inches='tight')

With main:
image

With my branch:
image

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:

image

I propose to open a new issue to track the remaining small offset.

PR checklist

@github-actionsgithub-actionsbot added topic: geometry managerLayoutEngine, Constrained layout, Tight layout topic: canvas and figure manager labelsDec 17, 2024
@@ -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)
Copy link
MemberAuthor

@rcomerrcomerDec 17, 2024
edited
Loading

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.

@rcomerrcomer added the PR: bugfixPull requests that fix identified bugs labelDec 17, 2024
Copy link
Member

@jklymakjklymak left a 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?

@rcomer
Copy link
MemberAuthor

rcomer commentedDec 18, 2024
edited
Loading

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 thatAxes.inset_axes' locator works without a renderer.

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).

jklymak reacted with thumbs up emoji

@jklymak
Copy link
Member

OK< so there is still a small registration issue. Thanks for checking.

@jklymakjklymak merged commitdc63ec7 intomatplotlib:mainDec 18, 2024
41 of 42 checks passed
@rcomerrcomer deleted the inset_axes-renderer branchDecember 18, 2024 15:52
@QuLogicQuLogic added this to thev3.11.0 milestoneDec 18, 2024
@rcomer
Copy link
MemberAuthor

I propose to open a new issue to track the remaining small offset.

#29383

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
PR: bugfixPull requests that fix identified bugstopic: canvas and figure managertopic: geometry managerLayoutEngine, Constrained layout, Tight layout
Projects
None yet
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

[Bug]: colorbar doesn't register inset_axis as cax
4 participants
@rcomer@jklymak@timhoffm@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp