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

BUG: boxplot does not set limits of axis #5517

Closed
aseyboldt opened this issue Nov 14, 2013 · 7 comments · Fixed by #8126
Closed

BUG: boxplot does not set limits of axis #5517

aseyboldt opened this issue Nov 14, 2013 · 7 comments · Fixed by #8126
Labels
Milestone

Comments

@aseyboldt
Copy link

DataFrame.boxplot fails to properly set the limits of the y-axis is this example:

df = pd.DataFrame({'X': [1, 0, 1, 0],
                   'Y': [1, 0, 1, 0],
                   'Z': [1, 0, 1, 0],
                   #'M': [1, 0, 1, 0],
                   'B': list("XXYY")}, 
                  index=list("UUVV"))

print df
"""
   B  X  Y  Z
U  X  1  1  1
U  X  0  0  0
V  Y  1  1  1
V  Y  0  0  0
"""

df.boxplot(by='B')

I would expect the y-axis to go from 0 to 1, not -0.06 to 0.06.
If I uncomment the M it works.

I use pandas 0.12.0 and matplotlib 1.3.1

Uploading boxplot.png . . .

@aseyboldt
Copy link
Author

Attaching the image did not work as I expected. The image is here:
http://nbviewer.ipython.org/7475835

@jorisvandenbossche
Copy link
Member

Note that it also works when you comment both M and Z eg (so you only have two columns). So it seems it has something to do with the fourth empty ax.

EDIT: It's not really a pandas bug (but could maybe solved in pandas), but it also happens if you do it yourself manually in matplotlib. Due to the shared axes, there goes something wrong with the limits when there is an empty subplot.

@jorisvandenbossche
Copy link
Member

It seems this should be fixed in matplotlib master: matplotlib/matplotlib#2356 and matplotlib/matplotlib#2357

@aseyboldt
Copy link
Author

I can confirm that this is fixed in matplotlib master.

@jreback
Copy link
Contributor

jreback commented Nov 27, 2013

is this still a bug? or just in matplotlib? anything to do?

@jorisvandenbossche
Copy link
Member

It's a bug in matplotlib, which it is fixed in matplotlib master, and not a real pandas bug. But it would be possible to workaround it in pandas (as it produces a wrong boxplot by only using pandas code). But I do not know how easy and/or necessary this would be.

@jreback
Copy link
Contributor

jreback commented Nov 27, 2013

ok....prob by the time 0.14 comes out, will just close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants