Skip to content

Commit

Permalink
BUG: The setting xrot=0 in DataFrame.hist() doesn't work with by and …
Browse files Browse the repository at this point in the history
  • Loading branch information
souvik3333 authored and AlexKirko committed Dec 29, 2019
1 parent ededc62 commit b195dd6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ Plotting
- :func:`set_option` now validates that the plot backend provided to ``'plotting.backend'`` implements the backend when the option is set, rather than when a plot is created (:issue:`28163`)
- :meth:`DataFrame.plot` now allow a ``backend`` keyword argument to allow changing between backends in one session (:issue:`28619`).
- Bug in color validation incorrectly raising for non-color styles (:issue:`29122`).
- Bug in :meth:`DataFrame.hist`, ``xrot=0`` does not work with ``by`` and subplots (:issue:`30288`).

Groupby/resample/rolling
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
3 changes: 2 additions & 1 deletion pandas/plotting/_matplotlib/hist.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ def _grouped_hist(
def plot_group(group, ax):
ax.hist(group.dropna().values, bins=bins, **kwargs)

xrot = xrot or rot
if xrot is None:
xrot = rot

fig, axes = _grouped_plot(
plot_group,
Expand Down
18 changes: 18 additions & 0 deletions pandas/tests/plotting/test_hist_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,24 @@ def test_tight_layout(self):

tm.close()

def test_hist_subplot_xrot(self):
# GH 30288
df = DataFrame(
{
"length": [1.5, 0.5, 1.2, 0.9, 3],
"animal": ["pig", "rabbit", "pig", "pig", "rabbit"],
}
)
axes = _check_plot_works(
df.hist,
filterwarnings="always",
column="length",
by="animal",
bins=5,
xrot=0,
)
self._check_ticks_props(axes, xrot=0)


@td.skip_if_no_mpl
class TestDataFrameGroupByPlots(TestPlotBase):
Expand Down

0 comments on commit b195dd6

Please sign in to comment.