Skip to content

Commit 51d30cf

Browse files
committed
BUG: pass sharex and sharey in grouped_hist
1 parent 40be825 commit 51d30cf

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

doc/source/release.rst

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ pandas 0.12
297297
- Fixed bug where a 1xN DataFrame would barf on a 1xN mask (:issue:`4071`)
298298
- Fixed running of ``tox`` under python3 where the pickle import was getting
299299
rewritten in an incompatible way (:issue:`4062`, :issue:`4063`)
300+
- Fixed bug where sharex and sharey were not being passed to grouped_hist
301+
(:issue:`4089`)
300302

301303

302304
pandas 0.11.0

doc/source/v0.12.0.txt

+2
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ Bug Fixes
439439
- Fixed bug where a 1xN DataFrame would barf on a 1xN mask (:issue:`4071`)
440440
- Fixed running of ``tox`` under python3 where the pickle import was getting
441441
rewritten in an incompatible way (:issue:`4062`, :issue:`4063`)
442+
- Fixed bug where sharex and sharey were not being passed to grouped_hist
443+
(:issue:`4089`)
442444

443445
See the :ref:`full release notes
444446
<release>` or issue tracker

pandas/tests/test_graphics.py

+33
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
import numpy as np
15+
from numpy import random
1516

1617
from numpy.testing import assert_array_equal
1718
from numpy.testing.decorators import slow
@@ -947,6 +948,38 @@ def test_grouped_hist(self):
947948
self.assertRaises(AttributeError, plotting.grouped_hist, df.A,
948949
by=df.C, foo='bar')
949950

951+
@slow
952+
def test_axis_shared(self):
953+
# GH4089
954+
import matplotlib.pyplot as plt
955+
def tick_text(tl):
956+
return [x.get_text() for x in tl]
957+
958+
n = 100
959+
df = DataFrame({'gender': np.array(['Male', 'Female'])[random.randint(2, size=n)],
960+
'height': random.normal(66, 4, size=n),
961+
'weight': random.normal(161, 32, size=n)})
962+
ax1, ax2 = df.hist(column='height', by=df.gender, sharex=True)
963+
self.assert_(ax1._shared_x_axes.joined(ax1, ax2))
964+
self.assertFalse(ax1._shared_y_axes.joined(ax1, ax2))
965+
self.assert_(ax2._shared_x_axes.joined(ax1, ax2))
966+
self.assertFalse(ax2._shared_y_axes.joined(ax1, ax2))
967+
plt.close('all')
968+
969+
ax1, ax2 = df.hist(column='height', by=df.gender, sharey=True)
970+
self.assertFalse(ax1._shared_x_axes.joined(ax1, ax2))
971+
self.assert_(ax1._shared_y_axes.joined(ax1, ax2))
972+
self.assertFalse(ax2._shared_x_axes.joined(ax1, ax2))
973+
self.assert_(ax2._shared_y_axes.joined(ax1, ax2))
974+
plt.close('all')
975+
976+
ax1, ax2 = df.hist(column='height', by=df.gender, sharex=True,
977+
sharey=True)
978+
self.assert_(ax1._shared_x_axes.joined(ax1, ax2))
979+
self.assert_(ax1._shared_y_axes.joined(ax1, ax2))
980+
self.assert_(ax2._shared_x_axes.joined(ax1, ax2))
981+
self.assert_(ax2._shared_y_axes.joined(ax1, ax2))
982+
950983
def test_option_mpl_style(self):
951984
set_option('display.mpl_style', 'default')
952985
set_option('display.mpl_style', None)

pandas/tools/plotting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
19281928
if by is not None:
19291929

19301930
axes = grouped_hist(data, by=by, ax=ax, grid=grid, figsize=figsize,
1931-
**kwds)
1931+
sharex=sharex, sharey=sharey, **kwds)
19321932

19331933
for ax in axes.ravel():
19341934
if xlabelsize is not None:

0 commit comments

Comments
 (0)