-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Pandas rendering minor ticks in matplotlib sublots with shared axes #10657
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
Comments
To add to this, the bug shown in the notebook linked above happens in
The bug does not happen with:
A pandas regression? |
Thanks. It probably is a maybe a regression on our end. We kind of take over the axes and use our own logic for determining what to draw. Your plot appears to work when you pass in |
Yes, you're right. To be consistent with the Happy to attempt a first PR if someone can point me in the direction of the file(s) that might have introduced this regression! |
@sinhrks am I correct in thinking that this is buggy? In [25]: x = pd.DataFrame(list(zip(range(10), range(0, -10, -1))), columns=['a', 'b'])
In [26]: x.index = pd.date_range('2000-01-01', freq='Q', periods=10)
In [27]: fig, ax = plt.subplots(2, 1, sharex=True)
In [28]: x.plot(subplots=True, ax=ax)
Out[28]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x116b96630>,
<matplotlib.axes._subplots.AxesSubplot object at 0x117580198>], dtype=object)
In [29]: plt.savefig('nosavefig.png')
In [30]: fig, ax = plt.subplots(2, 1, sharex=True)
In [31]: x.plot(subplots=True, ax=ax, sharex=True)
/Users/tom.augspurger/Envs/py3/lib/python3.4/site-packages/pandas/tools/plotting.py:3218: UserWarning: When passing multiple axes, sharex and sharey are ignored.These settings must be specified when creating axes
"These settings must be specified when creating axes", UserWarning)
Out[31]:
array([<matplotlib.axes._subplots.AxesSubplot object at 0x117deb940>,
<matplotlib.axes._subplots.AxesSubplot object at 0x10c64f828>], dtype=object)
In [32]: plt.savefig('with_share.png')
I haven't looked at this section in a while. |
I think it's 015fc62 that's the problem. Given the stated intentions of that commit, it's above my pay grade to determine whether this new behaviour is a feature or a bug! |
@TomAugspurger Yes, major/minor ticklabel should be displayed when |
cc @JanSchulz Do you remember in #9740 how the interaction of |
@TomAugspurger sorry, no idea whats going wrong here. I only tested (optimized for...) a gridspec without sharex, seems that I overlooked this case :-( |
When the plot method of a dataframe is passed an
ax
keyword to render to a matplotlib subplot, the minor ticks and their labels are rendered regardless of whethersharex|y=True
. The major ticks/labels are correctly removed.Here's a short notebook that reproduces the issue. Note that the minor ticks are included in the upper axes of the final figure.
I am 90% certain this is a regression, but I wasn't able to pin down which version of pandas or matplotlib prompted this bug. Nor was I able to figure out whether this was due to pandas or matplotlib.
The text was updated successfully, but these errors were encountered: