Skip to content

Commit

Permalink
BUG: Series.plot(kind="pie") does not respect ylabel argument
Browse files Browse the repository at this point in the history
  • Loading branch information
Abel Tavares committed Apr 14, 2024
1 parent 6e09e97 commit 48c3abe
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Expand Up @@ -37,6 +37,7 @@ Other enhancements
- Users can globally disable any ``PerformanceWarning`` by setting the option ``mode.performance_warnings`` to ``False`` (:issue:`56920`)
- :meth:`Styler.format_index_names` can now be used to format the index and column names (:issue:`48936` and :issue:`47489`)
- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
- :meth:`Series.plot` and :meth:`DataFrame.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`)

.. ---------------------------------------------------------------------------
.. _whatsnew_300.notable_bug_fixes:
Expand Down
2 changes: 2 additions & 0 deletions pandas/plotting/_matplotlib/core.py
Expand Up @@ -784,6 +784,8 @@ def _adorn_subplots(self, fig: Figure) -> None:
# ylabel will set it as ylabel in the plot.
if self.ylabel is not None:
ax.set_ylabel(pprint_thing(self.ylabel))
else:
ax.set_ylabel("")

ax.grid(self.grid)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/frame/test_frame.py
Expand Up @@ -1629,7 +1629,7 @@ def test_pie_df_subplots(self):
for ax in axes:
_check_text_labels(ax.texts, df.index)
for ax, ylabel in zip(axes, df.columns):
assert ax.get_ylabel() == ylabel
assert ax.get_ylabel() == ""

def test_pie_df_labels_colors(self):
df = DataFrame(
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/plotting/test_series.py
Expand Up @@ -378,7 +378,7 @@ def test_pie_series(self):
)
ax = _check_plot_works(series.plot.pie)
_check_text_labels(ax.texts, series.index)
assert ax.get_ylabel() == "YLABEL"
assert ax.get_ylabel() == ""

def test_pie_series_no_label(self):
series = Series(
Expand Down

0 comments on commit 48c3abe

Please sign in to comment.