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

extra ticklocs and ticklabels when plotting with bar(log=True) in matplotlib >= 1.3 #2419

Closed
cpcloud opened this issue Sep 13, 2013 · 2 comments

Comments

@cpcloud
Copy link

cpcloud commented Sep 13, 2013

with matplotlib >= 1.3 i see the following behavior:

In [6]: s = [200, 500]

In [7]: fig = figure()

In [8]: ax = fig.add_subplot(111)

In [10]: ax.bar([0, 1], s, log=True, bottom=1)
Out[10]: <Container object of 2 artists>

In [12]: ax.yaxis.get_ticklocs()
Out[12]: array([     0.1,      1. ,     10. ,    100. ,   1000. ,  10000. ])

In [15]: [x.get_text() for x in ax.yaxis.get_ticklabels()]
Out[15]:
['',
 '$\\mathdefault{10^{0}}$',
 '$\\mathdefault{10^{1}}$',
 '$\\mathdefault{10^{2}}$',
 '$\\mathdefault{10^{3}}$',
 '']

The corresponding plot is:

i-can-haz-lawg-plawt

Why are there empty tick labels and tick locs that aren't actually in the plot? Am I missing something? I don't observe this behavior in 1.2.1

In [7]: [x.get_text() for x in ax.yaxis.get_ticklabels()]
Out[7]:
['$\\mathdefault{10^{0}}$',
 '$\\mathdefault{10^{1}}$',
 '$\\mathdefault{10^{2}}$',
 '$\\mathdefault{10^{3}}$']

In [8]: ax.yaxis.get_ticklocs()
Out[8]: array([    1.,    10.,   100.,  1000.])

In [10]: matplotlib.__version__
Out[10]: '1.2.1'
@cpcloud
Copy link
Author

cpcloud commented Sep 13, 2013

I'm bisecting this now, just in case anyone was thinking of working on this.

@cpcloud
Copy link
Author

cpcloud commented Sep 13, 2013

closing....

just read this:

commit 4c0f3f3
Author: Daniel Hyams <dhyams@gitdev.(none)>
Date: Sat Jan 19 19:14:03 2013 -0500

Modifications to MultipleLocator and LogLocator, so that the locators will
give locations one past what they really need to. This is necessary, because
in situations where round off error matters, we want the locator to offer
more that it really thinks it needs to. The clipping of ticks still takes
place in the Axis class, so it's perfectly fine to add more locs than necessary.

In fact, matplotlib relies on the clipping behavior in the Axis class already
to not draw ticks outside of the limits of the axis.

@cpcloud cpcloud closed this as completed Sep 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant