Skip to content

Commit d003019

Browse files
committed
VIS: Apply xlabel and ylabel if passed to plot.hist().
1 parent e660f2c commit d003019

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pandas/plotting/_matplotlib/hist.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def __init__(
5959
) -> None:
6060
self.bins = bins # use mpl default
6161
self.bottom = bottom
62+
self.xlabel = kwargs.get("xlabel")
63+
self.ylabel = kwargs.get("ylabel")
6264
# Do not call LinePlot.__init__ which may fill nan
6365
MPLPlot.__init__(self, data, **kwargs)
6466

@@ -170,9 +172,11 @@ def _make_plot_keywords(self, kwds, y):
170172

171173
def _post_plot_logic(self, ax: Axes, data) -> None:
172174
if self.orientation == "horizontal":
173-
ax.set_xlabel("Frequency")
175+
ax.set_xlabel("Frequency" if self.xlabel is None else self.xlabel)
176+
ax.set_ylabel(self.ylabel)
174177
else:
175-
ax.set_ylabel("Frequency")
178+
ax.set_xlabel(self.xlabel)
179+
ax.set_ylabel("Frequency" if self.ylabel is None else self.ylabel)
176180

177181
@property
178182
def orientation(self) -> PlottingOrientation:

0 commit comments

Comments
 (0)