From 0ac3bfa9b51a5a173dff6e3fd77069a571402f58 Mon Sep 17 00:00:00 2001 From: rraadd88 Date: Wed, 2 Oct 2024 19:13:10 -0400 Subject: [PATCH] Update hist.py --- pandas/plotting/_matplotlib/hist.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandas/plotting/_matplotlib/hist.py b/pandas/plotting/_matplotlib/hist.py index 97e510982ab93..8b6fbbef2fd83 100644 --- a/pandas/plotting/_matplotlib/hist.py +++ b/pandas/plotting/_matplotlib/hist.py @@ -447,6 +447,13 @@ def hist_series( ax = fig.gca() elif ax.get_figure() != fig: raise AssertionError("passed axis not bound to passed figure") + + ## inferring xlabel from the Series + if hasattr(self,'name'): + xlabel=self.name + else: + xlabel=None + values = self.dropna().values if legend: kwds["label"] = self.name @@ -454,6 +461,12 @@ def hist_series( if legend: ax.legend() ax.grid(grid) + + ## setting xlabel + ax.set( + xlabel=xlabel + ) + axes = np.array([ax]) set_ticks_props(