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 18, 2024
1 parent f86f9f2 commit b494748
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
14 changes: 14 additions & 0 deletions doc/source/whatsnew/v3.0.0.rst
Expand Up @@ -39,6 +39,7 @@ Other enhancements
- :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:`DataFrame.fillna` and :meth:`Series.fillna` can now accept ``value=None``; for non-object dtype the corresponding NA value will be used (:issue:`57723`)
- :meth:`Series.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 Expand Up @@ -341,6 +342,19 @@ Performance improvements

Bug fixes
~~~~~~~~~
- Fixed bug in :class:`SparseDtype` for equal comparison with na fill value. (:issue:`54770`)
- Fixed bug in :meth:`.DataFrameGroupBy.median` where nat values gave an incorrect result. (:issue:`57926`)
- Fixed bug in :meth:`DataFrame.cumsum` which was raising ``IndexError`` if dtype is ``timedelta64[ns]`` (:issue:`57956`)
- Fixed bug in :meth:`DataFrame.eval` and :meth:`DataFrame.query` which caused an exception when using NumPy attributes via ``@`` notation, e.g., ``df.eval("@np.floor(a)")``. (:issue:`58041`)
- Fixed bug in :meth:`DataFrame.join` inconsistently setting result index name (:issue:`55815`)
- Fixed bug in :meth:`DataFrame.to_string` that raised ``StopIteration`` with nested DataFrames. (:issue:`16098`)
- Fixed bug in :meth:`DataFrame.transform` that was returning the wrong order unless the index was monotonically increasing. (:issue:`57069`)
- Fixed bug in :meth:`DataFrame.update` bool dtype being converted to object (:issue:`55509`)
- Fixed bug in :meth:`DataFrameGroupBy.apply` that was returning a completely empty DataFrame when all return values of ``func`` were ``None`` instead of returning an empty DataFrame with the original columns and dtypes. (:issue:`57775`)
- Fixed bug in :meth:`Series.diff` allowing non-integer values for the ``periods`` argument. (:issue:`56607`)
- Fixed bug in :meth:`Series.rank` that doesn't preserve missing values for nullable integers when ``na_option='keep'``. (:issue:`56976`)
- Fixed bug in :meth:`Series.replace` and :meth:`DataFrame.replace` inconsistently replacing matching instances when ``regex=True`` and missing values are present. (:issue:`56599`)
- Fixed bug in :meth:`read_csv` raising ``TypeError`` when ``index_col`` is specified and ``na_values`` is a dict containing the key ``None``. (:issue:`57547`)

Categorical
^^^^^^^^^^^
Expand Down
4 changes: 1 addition & 3 deletions pandas/plotting/_matplotlib/core.py
Expand Up @@ -2077,9 +2077,6 @@ def _make_plot(self, fig: Figure) -> None:

for i, (label, y) in enumerate(self._iter_data(data=self.data)):
ax = self._get_ax(i)
if label is not None:
label = pprint_thing(label)
ax.set_ylabel(label)

kwds = self.kwds.copy()

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

idx = [pprint_thing(v) for v in self.data.index]
# `label` is intentionally unused but is required for unpacking the tuple
labels = kwds.pop("labels", idx)
# labels is used for each wedge's labels
# Blank out labels for values of 0 so they don't overlap
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 b494748

Please sign in to comment.