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

Proplot changes names of colormaps to lowercase, breaking matplotlib.pyplot.get_cmap #434

Open
scottstanie opened this issue Aug 2, 2023 · 0 comments

Comments

@scottstanie
Copy link
Contributor

Description

The names of available colormaps change after running import proplot. This makes it harder to insert proplot into existing scripts which contain other plots.

Steps to reproduce

In [1]: import matplotlib.pyplot as plt
In [3]: plt.get_cmap('RdBu')
Out[3]: <matplotlib.colors.LinearSegmentedColormap at 0x12745cbe0>

In [4]: import proplot as pplt
In [6]: plt.get_cmap('RdBu')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[6], line 1
----> 1 plt.get_cmap('RdBu')

File ~/miniconda3/envs/mapping/lib/python3.10/site-packages/matplotlib/cm.py:190, in get_cmap(name, lut)
    188 if isinstance(name, colors.Colormap):
    189     return name
--> 190 _api.check_in_list(sorted(_cmap_registry), name=name)
    191 if lut is None:
    192     return _cmap_registry[name]

File ~/miniconda3/envs/mapping/lib/python3.10/site-packages/matplotlib/_api/__init__.py:126, in check_in_list(_values, _print_supported_values, **kwargs)
    124 if val not in values:
    125     if _print_supported_values:
--> 126         raise ValueError(
    127             f"{val!r} is not a valid value for {key}; "
    128             f"supported values are {', '.join(map(repr, values))}")
    129     else:
    130         raise ValueError(f"{val!r} is not a valid value for {key}")

ValueError: 'RdBu' is not a valid value for name; supported values are '538', 'accent', 'acton', 'afmhot', 'algae', 'amp', 'autumn', 'balance', 'bam', 'bamako', 'bamo', 'batlow', 'batlowk', 'batloww', 'berlin', 'bilbao', 'binary', 'blues', 'blues1', 'blues2', 'blues3', 'blues4', 'blues5', 'blues6', 'blues7', 'blues8', 'blues9', 'bmh', 'bone', 'boreal', 'br', 'brbg', 'brg', 'broc', 'broco', 'browns1', 'browns2', 'browns3', 'browns4', 'browns5', 'browns6', 'browns7', 'browns8', 'browns9', 'buda', 'bugn', 'bukavu', 'bupu', 'bwr', 'cividis', 'classic', 'cmrmap', 'coldhot', 'colorblind', 'colorblind10', 'cool', 'coolwarm', 'copper', 'cork', 'corko', 'crest', 'cubehelix', 'curl', 'dark2', 'davos', 'deep', 'default', 'delta', 'dense', 'devon', 'div', 'drywet', 'dusk', 'fes', 'fire', 'flag', 'flare', 'flatui', 'ggplot', 'gist_earth', 'gist_gray', 'gist_heat', 'gist_ncar', 'gist_rainbow', 'gist_stern', 'gist_yarg', 'glacial', 'gnbu', 'gnuplot', 'gnuplot2', 'gray', 'greens', 'greens1', 'greens2', 'greens3', 'greens4', 'greens5', 'greens6', 'greens7', 'greens8', 'greys', 'haline', 'hawaii', 'hot', 'hsv', 'ice', 'icefire', 'imola', 'inferno', 'jet', 'lajolla', 'lapaz', 'lisbon', 'magma', 'mako', 'marine', 'matter', 'mono', 'monocycle', 'negpos', 'nipy_spectral', 'nuuk', 'ocean', 'oleron', 'oranges', 'oranges1', 'oranges2', 'oranges3', 'oranges4', 'orrd', 'oslo', 'oxy', 'paired', 'pastel1', 'pastel2', 'phase', 'pink', 'piyg', 'plasma', 'prgn', 'prism', 'pubu', 'pubugn', 'puor', 'purd', 'purples', 'purples1', 'purples2', 'purples3', 'qual1', 'qual2', 'rainbow', 'rdbu', 'rdgy', 'rdpu', 'rdylbu', 'rdylgn', 'reds', 'reds1', 'reds2', 'reds3', 'reds4', 'reds5', 'rocket', 'roma', 'romao', 'seaborn', 'seismic', 'set1', 'set2', 'set3', 'solar', 'spectral', 'speed', 'spring', 'stellar', 'summer', 'sunrise', 'sunset', 'tab10', 'tab20', 'tab20b', 'tab20c', 'tableau', 'tempo', 'terrain', 'thermal', 'tofino', 'tokyo', 'turbid', 'turbo', 'turku', 'twilight', 'vanimo', 'vik', 'viko', 'viridis', 'vlag', 'winter', 'wistia', 'yellows1', 'yellows2', 'yellows3', 'yellows4', 'ylgn', 'ylgnbu', 'ylorbr', 'ylorrd'

Expected behavior: The matplotlib get_cmap was expected to work the same before and after importing proplot.

Equivalent steps in matplotlib

Example contains the matplotlib version.
Note that using lowercase before importing proplot errors, so one can't change all cmap names to lowercase.

Proplot version

In [2]: import matplotlib; print(matplotlib.__version__)
3.4.3

In [5]: pplt.__version__
Out[5]: '0.9.7'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant