BUG: boxplot does not set limits of axis #5517

Closed
aseyboldt opened this Issue Nov 14, 2013 · 7 comments

Comments

Projects
None yet
3 participants

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 . . .

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

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.

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

I can confirm that this is fixed in matplotlib master.

Contributor

jreback commented Nov 27, 2013

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

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.

Contributor

jreback commented Nov 27, 2013

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

@jreback jreback modified the milestone: 0.15.0, 0.14.0 Mar 28, 2014

@jreback jreback modified the milestone: 0.15.1, 0.15.0 Aug 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment