diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index 8dac952874f89..1fdfd99d3ff53 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -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 diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 48875114794d9..7559b042ea7e7 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -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() diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 62540a15f47bd..2fab7d0fdbc74 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -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", diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index d0ed5cb754c40..c49354816b8b0 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -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"