Skip to content
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
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 @@ -828,6 +828,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