Skip to content

Commit 0ac3bfa

Browse files
authored
Update hist.py
1 parent ba7e83d commit 0ac3bfa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/plotting/_matplotlib/hist.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,26 @@ def hist_series(
447447
ax = fig.gca()
448448
elif ax.get_figure() != fig:
449449
raise AssertionError("passed axis not bound to passed figure")
450+
451+
## inferring xlabel from the Series
452+
if hasattr(self,'name'):
453+
xlabel=self.name
454+
else:
455+
xlabel=None
456+
450457
values = self.dropna().values
451458
if legend:
452459
kwds["label"] = self.name
453460
ax.hist(values, bins=bins, **kwds)
454461
if legend:
455462
ax.legend()
456463
ax.grid(grid)
464+
465+
## setting xlabel
466+
ax.set(
467+
xlabel=xlabel
468+
)
469+
457470
axes = np.array([ax])
458471

459472
set_ticks_props(

0 commit comments

Comments
 (0)