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 2 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
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Bug fixes
~~~~~~~~~
- Fix some cases for subclasses that define their ``_constructor`` properties as general callables (:issue:`46018`)
- Fixed "longtable" formatting in :meth:`.Styler.to_latex` when ``column_format`` is given in extended format (:issue:`46037`)
-
- Fix showing "None" as ylabel in :meth:`Series.plot` when not setting ylabel (:issue:`46129`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only for specific plots yes?

move to 1.5 Bug fixes for visualization


.. ---------------------------------------------------------------------------

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