Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [ ] I have confirmed this bug exists on the latest version of pandas.

  • [ ] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

chunk = pd.DataFrame(index=[0, 1, 2])

df = pd.concat([chunk.assign(y=i, i=i) for i in range(3)])

df.groupby("i")["y"].plot(legend=True, cmap="tab20");

Issue Description

The above code snippet demonstrates that cmap="tab20" is not respected. The parameter is respected in DataFrame.plot, which can be checked by viewing

df.plot(cmap="tab20")

Expected Behavior

The cmap parameter should be correctly handled

Installed Versions

INSTALLED VERSIONS ------------------ commit : a671b5a8bf5dd13fb19f0e88edc679bc9e15c673 python : 3.11.2.final.0 python-bits : 64 OS : Darwin OS-release : 23.1.0 Version : Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 2.1.4 numpy : 1.26.2 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 68.2.2 pip : 23.3.1 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.19.0 pandas_datareader : None bs4 : 4.12.2 bottleneck : None dataframe-api-compat: None fastparquet : None fsspec : None gcsfs : None matplotlib : 3.8.2 numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : 1.11.4 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2023.4 qtpy : None pyqt5 : None

Comment From: zhuoyahuang

take

Comment From: zhuoyahuang

Hi @matteosantama Can you please attach a screenshot if this is still an issue? I couldn't reproduce the problem, I've tried a few different colormaps and the cmap feature looks good to me

Image

Comment From: matteosantama

You can see the problem in your screenshot. In your first plot, all three lines have the same color. They should have three different colors, corresponding to the three group-by keys.

For example, see what you get if you don't pass any colormap

df.groupby("i")["y"].plot(legend=True);

Image

You should be able to control the colors used.

Just a heads up, though, it looks like the right parameter is colormap, not cmap: https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.SeriesGroupBy.plot.html#pandas.core.groupby.SeriesGroupBy.plot

The problem persists with the right parameter, though.

Comment From: zhuoyahuang

Thanks for explaining much appreciated. I'll look into this issue deeper.