Skip to content

Fix showing "None" as ylabel in :meth:Series.plot when not setting ylabel #46445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 21, 2022
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
7 changes: 7 additions & 0 deletions doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ did not have the same index as the input.
df.groupby('a', dropna=True).transform(lambda x: x)
df.groupby('a', dropna=True).transform('sum')

.. _whatsnew_150.notable_bug_fixes.visualization:

Styler
^^^^^^

- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`)

.. _whatsnew_150.notable_bug_fixes.notable_bug_fix2:

notable_bug_fix2
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def _compute_plot_data(self):
if isinstance(data, ABCSeries):
label = self.label
if label is None and data.name is None:
label = "None"
label = ""
if label is None:
# We'll end up with columns of [0] instead of [None]
data = data.to_frame()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ def test_line_label_none(self):
assert ax.get_legend() is None

ax = s.plot(legend=True)
assert ax.get_legend().get_texts()[0].get_text() == "None"
assert ax.get_legend().get_texts()[0].get_text() == ""

@pytest.mark.parametrize(
"props, expected",
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_label(self):
self.plt.close()
_, ax = self.plt.subplots()
ax = s.plot(legend=True, ax=ax)
self._check_legend_labels(ax, labels=["None"])
self._check_legend_labels(ax, labels=[""])
self.plt.close()
# get name from index
s.name = "NAME"
Expand Down