Skip to content
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

Ticks on top axis disappear if tick size is too large (when using bbox_inches='tight') #3514

Merged
merged 1 commit into from Sep 27, 2014

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Sep 18, 2014

This is a bug in Matplotlib 1.4 - the following script:

import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot([1,2,3])

for line in ax.xaxis.get_ticklines():
    line.set_markersize(17)

for line in ax.yaxis.get_ticklines():
    line.set_markersize(17)

fig.savefig('ticks.png', bbox_inches='tight')

produces the following output when using bbox_inches='tight':

ticks

When not setting bbox_inches='tight', the ticks are there:

ticks

Addendum: it turns out I noticed this because some of the image tests in my package were failing - however, this only caused an RMS difference of ~2 or so, so the tolerance has to be quite low to catch this!

@tacaswell
Copy link
Member

As a quick fix, try turning clipping off on the ticks. I assume what is going on here is a round-off error is the bounding box calculations and for clipping purposes the upper ticks are deemed to be 'outside' of the bounding box and dropped.

@tacaswell
Copy link
Member

Nevermind, that isn't a solution...

@mdboom mdboom self-assigned this Sep 18, 2014
@mdboom
Copy link
Member

mdboom commented Sep 18, 2014

A solution is attached. The issue here was realization that the y we get out of agg for the marker position has already been inverted by the time it comes to us, so the clipping path should also be "y increasing downward".

@astrofrog
Copy link
Contributor Author

I'm trying this out (ignore my previous message about it not working)

@mdboom
Copy link
Member

mdboom commented Sep 18, 2014

@astrofrog: Which backend are you using?

@astrofrog
Copy link
Contributor Author

Ok, this works for me, thanks @mdboom! (ignore my previous message about it not working)

@astrofrog
Copy link
Contributor Author

Just out of interest, will this be backported to 1.4.1?

@mdboom
Copy link
Member

mdboom commented Sep 18, 2014

This will make it into the next bugfix release, yes.

@tacaswell tacaswell modified the milestones: v1.4.1, v1.4.x Sep 18, 2014
(scanlines.max_y() + 1.0),
width + scanlines.max_x() + 1.0,
height - scanlines.min_y() + 1.0);
-1.0 - scanlines.max_x(),
Copy link
Member

Choose a reason for hiding this comment

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

Why did the x min/max get swapped?

Do I want to ask why it looks like the origin is in the lower right with the values increasing down and to the right?

tacaswell added a commit that referenced this pull request Sep 27, 2014
BUG : Ticks on top axis disappear if tick size is too large (when using bbox_inches='tight')
@tacaswell tacaswell merged commit 20741b5 into matplotlib:v1.4.x Sep 27, 2014
@mdboom mdboom deleted the large-ticks branch March 3, 2015 18: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.

None yet

4 participants