DataFrame.hist does not honor sharex or sharey set to True #4089

Closed
fonnesbeck opened this Issue Jun 30, 2013 · 13 comments

Comments

Projects
None yet
2 participants

Here is an example of the hist method called as a multi-panel plot via the by argument, with sharey=True and sharex=True. As you can observe in the plot at the bottom of the notebook, neither the x nor the y axis is shared among the subplots.

Running 0.11.1 on Python 2.7.2 (OS X 10.8.4).

Member

cpcloud commented Jul 1, 2013

so the issue is that using by doesn't pass the share* params. i'll see what i can do

Member

cpcloud commented Jul 1, 2013

@fonnesbeck thanks. pr coming

cpcloud was assigned Jul 1, 2013

cpcloud closed this in #4091 Jul 1, 2013

Sorry I did not get a chance to look at this last night. Unfortunately, though the update does cause the axes to be shared among the subplots, it seems to have introduced another bug: The histogram no longer appears in the plots. Here is the updated notebook. I have added additional plots showing that the histograms work with no sharing. When you use sharex only, nothing appears; when you use sharey only it creates incorrect y-axis limits altogether.

Member

cpcloud commented Jul 1, 2013

one issue is that the first axes is shared, so some of your data won't show up since it is outside of the range of those axes. however, there's an oddity there: why is it using those particular xaxis limits

Member

cpcloud commented Jul 1, 2013

can you confirm that this works with the data generated in pandas/tests/test_graphics.py:TestDataFrameGroupBypPlots.test_shared_axis?

It fails at test_time_series_plot_color_with_empty_kwargs:

nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
test_axis_shared (__main__.TestDataFrameGroupByPlots) ... ok
test_boxplot (__main__.TestDataFrameGroupByPlots) ... ok
test_grouped_hist (__main__.TestDataFrameGroupByPlots) ... ok
test_invalid_colormap (__main__.TestDataFrameGroupByPlots) ... ok
test_option_mpl_style (__main__.TestDataFrameGroupByPlots) ... ok
test_series_plot_color_kwargs (__main__.TestDataFrameGroupByPlots) ... ok
test_time_series_plot_color_kwargs (__main__.TestDataFrameGroupByPlots) ... ok
test_time_series_plot_color_with_empty_kwargs (__main__.TestDataFrameGroupByPlots) ... > /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(420)assertTrue()
-> raise self.failureException(msg)
(Pdb) c
FAIL

======================================================================
FAIL: test_time_series_plot_color_with_empty_kwargs (__main__.TestDataFrameGroupByPlots)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/fonnescj/Code/pandas/pandas/tests/test_graphics.py", line 912, in test_time_series_plot_color_with_empty_kwargs
    self.assert_(line_colors == ['b', 'g', 'r'])
AssertionError: False is not true

----------------------------------------------------------------------
Ran 8 tests in 24.977s

FAILED (failures=1)
Member

cpcloud commented Jul 1, 2013

is this from master? i fixed that a few commits ago. that had to with not closing plots

Yes:

~/Code/pandas/.git(branch:master) » more HEAD                   fonnescj@Cepeda
ref: refs/heads/master
Member

cpcloud commented Jul 1, 2013

what the sha1?

Member

cpcloud commented Jul 1, 2013

nvm i c that u have the latest since my test i there

Member

cpcloud commented Jul 1, 2013

did u run with nosetests? if not can u try that? it looks like u ran the file as an executable with python. if that's not the issue then i can reopen, as it seems like it might be mac specific

I get the following failures:

~/Code/pandas(branch:master*) » nosetests pandas/tests/test_graphics.py
.......F...F........................................
======================================================================
FAIL: test_time_series_plot_color_with_empty_kwargs (pandas.tests.test_graphics.TestDataFrameGroupByPlots)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/fonnescj/Code/pandas/pandas/tests/test_graphics.py", line 912, in test_time_series_plot_color_with_empty_kwargs
    self.assert_(line_colors == ['b', 'g', 'r'])
AssertionError: False is not true

======================================================================
FAIL: test_bar_log (pandas.tests.test_graphics.TestDataFramePlots)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/fonnescj/Code/pandas/pandas/tests/test_graphics.py", line 504, in test_bar_log
    self.assertEqual(ax.yaxis.get_ticklocs()[0], 1.0)
AssertionError: 0.10000000000000001 != 1.0

----------------------------------------------------------------------
Ran 52 tests in 101.801s

FAILED (failures=2)
Member

cpcloud commented Jul 1, 2013

Strange. The second one should be calling assert almost equal maybe with a precision argument . I thought that was fixed by a previous commit. The first one I'm not sure but I ll look into it.

cpcloud was unassigned by wesm Oct 12, 2016

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