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: don't pad axes for ticks if they aren't visible or axis off#11210

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

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedMay 9, 2018
edited
Loading

PR Summary

Since 1.5.3 (two years ago) we added:

defget_window_extent(self,*args,**kwargs):
"""
get the axes bounding box in display space; *args* and
*kwargs* are empty
"""
bbox=self.bbox
x_pad=self.xaxis.get_tick_padding()
y_pad=self.yaxis.get_tick_padding()
returnmtransforms.Bbox([[bbox.x0-x_pad,bbox.y0-y_pad],
[bbox.x1+x_pad,bbox.y1+y_pad]])

First, this seems like a funny place to put the padding for ticks - I'd have expected it to be in the axis bbox, not the axes bbox. But presumably someone wanted to know the extent of the axes and its ticks w/o knowing the rest of the decorators? The original issues that spurred#5683 seemed to be tight_layout not respecting outward ticks. IMHO this "fix" was wrong and the axis bboxes should include the ticks not theaxes,Butxaxis.get_tightbbox doesnot include the ticks even though it controls everything about the ticks.

Second,ax.set_axis_off sets aax.axison=False, but it doesn't change thevisibility of the axis, which is still True. I haven't fixed this, but it seems strange to have two flags that control the visibility of an axis.

Anyways, this is an easy fix given how things are now to make the tightbbox actually behave like there are no ticks present.

Closes:#11203

  • Probably needs a good test....
  • Milestoning 3.0 as this regression is very old.
importnumpyasnpfrommatplotlibimportpyplotasplt# axis ticks removedfig,ax=plt.subplots(figsize=(1,1))ax.matshow(np.ones((10,10)),cmap=plt.cm.Blues_r,aspect='auto')ax.set_xticklabels([])ax.set_yticklabels([])ax.axis('off')fig.tight_layout()fig.savefig('test_noticks.png',dpi=300,bbox_inches='tight',pad_inches=0,facecolor='red')

before

test_noticks

after

test_noticks

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant

@jklymakjklymak added this to thev3.0 milestoneMay 9, 2018
@jklymak
Copy link
MemberAuthor

test added....

@jklymakjklymak changed the titleFIX: don't pad axes for ticks if they aren't visible and axis offFIX: don't pad axes for ticks if they aren't visible or axis offMay 9, 2018
@phobsonphobson merged commit6665bc7 intomatplotlib:masterJun 5, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@phobsonphobsonphobson approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.0.0
Development

Successfully merging this pull request may close these issues.

tight_layout reserves tick space even if disabled
3 participants
@jklymak@phobson@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp