From 51d30cfa57d909fb43644959c594aa672cc884ff Mon Sep 17 00:00:00 2001 From: Phillip Cloud Date: Sun, 30 Jun 2013 21:14:03 -0400 Subject: [PATCH] BUG: pass sharex and sharey in grouped_hist --- doc/source/release.rst | 2 ++ doc/source/v0.12.0.txt | 2 ++ pandas/tests/test_graphics.py | 33 +++++++++++++++++++++++++++++++++ pandas/tools/plotting.py | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 513540698023f..2aa6e1a80085f 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -297,6 +297,8 @@ pandas 0.12 - Fixed bug where a 1xN DataFrame would barf on a 1xN mask (:issue:`4071`) - Fixed running of ``tox`` under python3 where the pickle import was getting rewritten in an incompatible way (:issue:`4062`, :issue:`4063`) + - Fixed bug where sharex and sharey were not being passed to grouped_hist + (:issue:`4089`) pandas 0.11.0 diff --git a/doc/source/v0.12.0.txt b/doc/source/v0.12.0.txt index b9fbc4d9cf806..60086e1c49ae7 100644 --- a/doc/source/v0.12.0.txt +++ b/doc/source/v0.12.0.txt @@ -439,6 +439,8 @@ Bug Fixes - Fixed bug where a 1xN DataFrame would barf on a 1xN mask (:issue:`4071`) - Fixed running of ``tox`` under python3 where the pickle import was getting rewritten in an incompatible way (:issue:`4062`, :issue:`4063`) + - Fixed bug where sharex and sharey were not being passed to grouped_hist + (:issue:`4089`) See the :ref:`full release notes ` or issue tracker diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index 15389ef687951..f1e4ef1106080 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -12,6 +12,7 @@ import numpy as np +from numpy import random from numpy.testing import assert_array_equal from numpy.testing.decorators import slow @@ -947,6 +948,38 @@ def test_grouped_hist(self): self.assertRaises(AttributeError, plotting.grouped_hist, df.A, by=df.C, foo='bar') + @slow + def test_axis_shared(self): + # GH4089 + import matplotlib.pyplot as plt + def tick_text(tl): + return [x.get_text() for x in tl] + + n = 100 + df = DataFrame({'gender': np.array(['Male', 'Female'])[random.randint(2, size=n)], + 'height': random.normal(66, 4, size=n), + 'weight': random.normal(161, 32, size=n)}) + ax1, ax2 = df.hist(column='height', by=df.gender, sharex=True) + self.assert_(ax1._shared_x_axes.joined(ax1, ax2)) + self.assertFalse(ax1._shared_y_axes.joined(ax1, ax2)) + self.assert_(ax2._shared_x_axes.joined(ax1, ax2)) + self.assertFalse(ax2._shared_y_axes.joined(ax1, ax2)) + plt.close('all') + + ax1, ax2 = df.hist(column='height', by=df.gender, sharey=True) + self.assertFalse(ax1._shared_x_axes.joined(ax1, ax2)) + self.assert_(ax1._shared_y_axes.joined(ax1, ax2)) + self.assertFalse(ax2._shared_x_axes.joined(ax1, ax2)) + self.assert_(ax2._shared_y_axes.joined(ax1, ax2)) + plt.close('all') + + ax1, ax2 = df.hist(column='height', by=df.gender, sharex=True, + sharey=True) + self.assert_(ax1._shared_x_axes.joined(ax1, ax2)) + self.assert_(ax1._shared_y_axes.joined(ax1, ax2)) + self.assert_(ax2._shared_x_axes.joined(ax1, ax2)) + self.assert_(ax2._shared_y_axes.joined(ax1, ax2)) + def test_option_mpl_style(self): set_option('display.mpl_style', 'default') set_option('display.mpl_style', None) diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index ef55319da185c..0052ed1cecbe4 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -1928,7 +1928,7 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None, if by is not None: axes = grouped_hist(data, by=by, ax=ax, grid=grid, figsize=figsize, - **kwds) + sharex=sharex, sharey=sharey, **kwds) for ax in axes.ravel(): if xlabelsize is not None: