Skip to content

Commit 99bc4b3

Browse files
author
Abel Tavares
committed
BUG: Series.plot(kind="pie") does not respect ylabel argument
1 parent f86f9f2 commit 99bc4b3

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Other enhancements
3939
- :meth:`Styler.format_index_names` can now be used to format the index and column names (:issue:`48936` and :issue:`47489`)
4040
- :meth:`DataFrame.cummin`, :meth:`DataFrame.cummax`, :meth:`DataFrame.cumprod` and :meth:`DataFrame.cumsum` methods now have a ``numeric_only`` parameter (:issue:`53072`)
4141
- :meth:`DataFrame.fillna` and :meth:`Series.fillna` can now accept ``value=None``; for non-object dtype the corresponding NA value will be used (:issue:`57723`)
42+
- :meth:`Series.plot` now correctly handle the ``ylabel`` parameter for pie charts, allowing for explicit control over the y-axis label (:issue:`58239`)
4243

4344
.. ---------------------------------------------------------------------------
4445
.. _whatsnew_300.notable_bug_fixes:

pandas/plotting/_matplotlib/core.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -2077,9 +2077,6 @@ def _make_plot(self, fig: Figure) -> None:
20772077

20782078
for i, (label, y) in enumerate(self._iter_data(data=self.data)):
20792079
ax = self._get_ax(i)
2080-
if label is not None:
2081-
label = pprint_thing(label)
2082-
ax.set_ylabel(label)
20832080

20842081
kwds = self.kwds.copy()
20852082

@@ -2090,6 +2087,7 @@ def blank_labeler(label, value):
20902087
return label
20912088

20922089
idx = [pprint_thing(v) for v in self.data.index]
2090+
# `label` is intentionally unused but is required for unpacking the tuple
20932091
labels = kwds.pop("labels", idx)
20942092
# labels is used for each wedge's labels
20952093
# Blank out labels for values of 0 so they don't overlap

pandas/tests/plotting/frame/test_frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ def test_pie_df_subplots(self):
16291629
for ax in axes:
16301630
_check_text_labels(ax.texts, df.index)
16311631
for ax, ylabel in zip(axes, df.columns):
1632-
assert ax.get_ylabel() == ylabel
1632+
assert ax.get_ylabel() == ""
16331633

16341634
def test_pie_df_labels_colors(self):
16351635
df = DataFrame(

pandas/tests/plotting/test_series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def test_pie_series(self):
378378
)
379379
ax = _check_plot_works(series.plot.pie)
380380
_check_text_labels(ax.texts, series.index)
381-
assert ax.get_ylabel() == "YLABEL"
381+
assert ax.get_ylabel() == ""
382382

383383
def test_pie_series_no_label(self):
384384
series = Series(

0 commit comments

Comments
 (0)