Skip to content

Pandas dataframe + groupby = failed zooming for x-axis ticks #15912

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

Closed
mp-v2 opened this issue Apr 5, 2017 · 2 comments · Fixed by #26185
Closed

Pandas dataframe + groupby = failed zooming for x-axis ticks #15912

mp-v2 opened this issue Apr 5, 2017 · 2 comments · Fixed by #26185
Labels
Duplicate Report Duplicate issue or pull request Visualization plotting

Comments

@mp-v2
Copy link

mp-v2 commented Apr 5, 2017

This was posted onto stackoverflow but it seems more like a bug than anything:

http://stackoverflow.com/questions/43242246/pandas-dataframe-groupby-failed-zooming-for-x-axis-ticks

@jorisvandenbossche
Copy link
Member

Smaller reproducible example:

In [43]: df = pd.DataFrame(np.random.randn(4, 2), columns=['A', 'B'], index=pd.MultiIndex.from_product([[2012, 2013], [1,2]]))

In [44]: df
Out[44]: 
               A         B
2012 1  0.144222  0.895911
     2  0.885869  0.075482
2013 1 -0.312316  0.705149
     2 -0.974501  1.443551

In [45]: df.plot()
Out[45]: <matplotlib.axes._subplots.AxesSubplot at 0x7f3e6a262ef0>

The xtick label formatter cannot really handle a MultiIndex, as once you zoom in, the labels are put at the wrong place.

But the same is true when eg having a string index. So just a non-numerical / non-datetime index has this issue.

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Apr 6, 2017

This is a duplicate of #7612

@jorisvandenbossche jorisvandenbossche added Duplicate Report Duplicate issue or pull request Visualization plotting labels Apr 6, 2017
@jorisvandenbossche jorisvandenbossche added this to the No action milestone Apr 6, 2017
nrebena pushed a commit to nrebena/pandas that referenced this issue Apr 23, 2019
nrebena pushed a commit to nrebena/pandas that referenced this issue Apr 24, 2019
Separate the test for pandas-dev#7612 and pandas-dev#22334, that are about string index,
and test for pandas-dev#15912, about multiindex.
jreback pushed a commit that referenced this issue Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants