Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: can't pass Colormap instance when plotting if using matplotlib >= 3.6 #49374

Closed
3 tasks done
zmoon opened this issue Oct 28, 2022 · 2 comments · Fixed by #49377
Closed
3 tasks done

BUG: can't pass Colormap instance when plotting if using matplotlib >= 3.6 #49374

zmoon opened this issue Oct 28, 2022 · 2 comments · Fixed by #49377
Labels
Bug Regression Functionality that used to work in a prior pandas version Visualization plotting
Milestone

Comments

@zmoon
Copy link
Contributor

zmoon commented Oct 28, 2022

Pandas version checks

  • 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 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 NOAA-CSL/MELODIES-MONET#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 : 91111fd
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

@zmoon zmoon added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 28, 2022
@mzeitlin11
Copy link
Member

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

@mzeitlin11 mzeitlin11 added Visualization plotting and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 28, 2022
@zmoon
Copy link
Contributor Author

zmoon commented Oct 28, 2022

Ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Regression Functionality that used to work in a prior pandas version Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants