Skip to content

BUG: pass sharex and sharey in grouped_hist #4091

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

Merged
merged 1 commit into from
Jul 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/source/v0.12.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
<release>` or issue tracker
Expand Down
33 changes: 33 additions & 0 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down