Skip to content

Commit d5f2e5c

Browse files
authored
Fix showing "None" as ylabel in :meth:Series.plot when not setting ylabel (pandas-dev#46445)
1 parent 96199e7 commit d5f2e5c

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

doc/source/whatsnew/v1.5.0.rst

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ did not have the same index as the input.
110110
df.groupby('a', dropna=True).transform(lambda x: x)
111111
df.groupby('a', dropna=True).transform('sum')
112112
113+
.. _whatsnew_150.notable_bug_fixes.visualization:
114+
115+
Styler
116+
^^^^^^
117+
118+
- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`)
119+
113120
.. _whatsnew_150.notable_bug_fixes.notable_bug_fix2:
114121

115122
notable_bug_fix2

pandas/plotting/_matplotlib/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ def _compute_plot_data(self):
458458
if isinstance(data, ABCSeries):
459459
label = self.label
460460
if label is None and data.name is None:
461-
label = "None"
461+
label = ""
462462
if label is None:
463463
# We'll end up with columns of [0] instead of [None]
464464
data = data.to_frame()

pandas/tests/plotting/frame/test_frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def test_line_label_none(self):
11881188
assert ax.get_legend() is None
11891189

11901190
ax = s.plot(legend=True)
1191-
assert ax.get_legend().get_texts()[0].get_text() == "None"
1191+
assert ax.get_legend().get_texts()[0].get_text() == ""
11921192

11931193
@pytest.mark.parametrize(
11941194
"props, expected",

pandas/tests/plotting/test_series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_label(self):
179179
self.plt.close()
180180
_, ax = self.plt.subplots()
181181
ax = s.plot(legend=True, ax=ax)
182-
self._check_legend_labels(ax, labels=["None"])
182+
self._check_legend_labels(ax, labels=[""])
183183
self.plt.close()
184184
# get name from index
185185
s.name = "NAME"

0 commit comments

Comments
 (0)