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.

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

Reproducible Example

import matplotlib as mpl
import pandas as pd

df = pd.DataFrame({"x": [0], "y": [0]})

df.plot.scatter(x="x", y="y", colormap=mpl.cm.get_cmap("Spectral"))

Issue Description

See more info in https://github.com/NOAA-CSL/MELODIES-MONET/issues/135 where I first ran into this.

Expected Behavior

Seems like replacing cmap = mpl.colormaps[self.colormap] with cmap = mpl.colormaps.get(self.colormap) will resolve this. This is 2nd option mentioned in the (doc) deprecation message:

Use ``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap(obj)`` instead.

Installed Versions

INSTALLED VERSIONS ------------------ commit : 91111fd99898d9dcaa6bf6bedb662db4108da6e6 python : 3.9.13.final.0 python-bits : 64 OS : Linux OS-release : 4.18.0-348.7.1.el8_5.x86_64 Version : #1 SMP Wed Dec 22 13:25:12 UTC 2021 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8 pandas : 1.5.1 numpy : 1.23.4 pytz : 2022.5 dateutil : 2.8.2 setuptools : 65.5.0 pip : 22.3 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.5.0 pandas_datareader: None bs4 : None bottleneck : None brotli : fastparquet : 0.8.3 fsspec : 2022.10.0 gcsfs : None matplotlib : 3.6.1 numba : 0.56.3 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None pyxlsb : None s3fs : 2022.10.0 scipy : 1.9.3 snappy : None sqlalchemy : None tables : None tabulate : None xarray : 2022.10.0 xlrd : None xlwt : None zstandard : None tzdata : None

Comment From: mzeitlin11

Thanks for reporting and investigating this @zmoon! A pr would be welcome to fix this.

Comment From: zmoon

Ok!