Pandas version checks

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

  • [X] 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

>>> pd.Series([1, 2, 3]).plot(color=None)
Traceback (most recent call last): Cell In[45], line 1 pd.Series([1, 2, 3]).plot(color=None) File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_core.py:1000 in __call__ return plot_backend.plot(data, kind=kind, **kwargs) File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\__init__.py:71 in plot plot_obj.generate() File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\core.py:452 in generate self._make_plot() File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\core.py:1369 in _make_plot colors = self._get_colors() File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\core.py:993 in _get_colors return get_standard_colors( File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\style.py:75 in get_standard_colors colors = _derive_colors( File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\style.py:132 in _derive_colors return _get_colors_from_color(color) File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\style.py:181 in _get_colors_from_color return list(_gen_list_of_colors_from_iterable(color)) File ~\Anaconda3\envs\latest\lib\site-packages\pandas\plotting\_matplotlib\style.py:214 in _gen_list_of_colors_from_iterable raise ValueError(f"Invalid color {x}")

ValueError: Invalid color None

Issue Description

DataFrame.plot has a color argument that allows None. Series.plot also has a color argument, but it does not allow None.

The existence of a color argument is not explicitly documented in either case. One would assume that color falls into this bucket:

**kwargs
Options to pass to matplotlib plotting method.

but that doesn't explain why it behaves differently between classes.

Also asked on Stack Overflow.

Expected Behavior

>>> pd.DataFrame([[1, 2, 3]]).plot(color=None)
<AxesSubplot:> # works

Installed Versions

INSTALLED VERSIONS ------------------ commit : 2e218d10984e9919f0296931d92ea851c6a6faf5 python : 3.10.9.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19043 machine : AMD64 processor : Intel64 Family 6 Model 142 Stepping 12, GenuineIntel byteorder : little LC_ALL : None LANG : en LOCALE : English_United States.1252 pandas : 1.5.3 numpy : 1.23.5 pytz : 2022.7 dateutil : 2.8.2 setuptools : 65.6.3 pip : 23.0.1 Cython : None pytest : None hypothesis : None sphinx : 5.0.2 blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.1 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.10.0 pandas_datareader: None bs4 : 4.11.1 bottleneck : 1.3.5 brotli : fastparquet : None fsspec : None gcsfs : None matplotlib : 3.7.0 numba : None numexpr : 2.8.4 odfpy : None openpyxl : 3.0.10 pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : None scipy : 1.10.0 snappy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None zstandard : None tzdata : None

Comment From: dannyi96

The delta b/w Series vs DataFrame implemention seems to be arise here: ( Post call to _validate_color_args )

DataFrame:

def _validate_color_args(self):
   ...
   ...

   self.kwds["color"]` ---> ends up being None

Series:

def _validate_color_args(self):
   ...
   ...

   self.kwds["color"]` ---> ends up being [None]

This delta between DataFrame vs Series seems to arise from here

https://github.com/pandas-dev/pandas/blob/eaacf8300a252c8e922eea3bd416d188ae0ccaa8/pandas/plotting/_matplotlib/core.py#L376-L383

Comment From: dannyi96

take

Comment From: igurin-invn

FWIW, I tried a workaround:

pd.Series([1, 2, 3]).plot(color=[None])

Gives the same error.