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 not compatible with matplotlib 3.6 #390

Open
swamidass opened this issue Sep 20, 2022 · 14 comments
Open

Proplot not compatible with matplotlib 3.6 #390

swamidass opened this issue Sep 20, 2022 · 14 comments

Comments

@swamidass
Copy link

Looks like the current version of proplot does not work with matplotlib==3.6 (though it works fine with 3.5).

The import:

import proplot as pplt

Throws:

AttributeError: module 'matplotlib.cm' has no attribute 'cmap_d'

From: proplot/colors.py:3111,

_cmap_database = _init_cmap_database()

This might be fixable by changing the reference to cmap_d to point instead to matplotlib.colormaps.

@zxdawn
Copy link

zxdawn commented Sep 21, 2022

Could you try the newest version of proplot?

pip install git+https://github.com/proplot-dev/proplot.git

@cvanelteren
Copy link

@zxdawn works for me

@swamidass
Copy link
Author

That worked. Perhaps push a release to pypi?

@ForceBru
Copy link

Could you try the newest version of proplot?

pip install git+https://github.com/proplot-dev/proplot.git

This downgraded Matplotlib from 3.6.1 to 3.5.3 for me...

@knaaptime
Copy link
Contributor

Could you try the newest version of proplot?

pip install git+https://github.com/proplot-dev/proplot.git

This downgraded Matplotlib from 3.6.1 to 3.5.3 for me...

same. Looking closer, the requirements.txt file only lists matplotlib>3.0, but this line still enforces <3.6

@knaaptime
Copy link
Contributor

(if i try to use proplot anyway in an environment with mpl 3.6.2 i get AttributeError: module 'matplotlib.cm' has no attribute 'cmap_d' )

@zxdawn
Copy link

zxdawn commented Nov 8, 2022

@knaaptime Yes, that's caused by matplotlib/matplotlib#22298.

@knaaptime
Copy link
Contributor

yup, just wanted to make sure you're aware since you asked for beta testers of the current dev install :)

Z2h-A6n added a commit to Z2h-A6n/proplot that referenced this issue Nov 22, 2022
Fixes Github issue proplot-dev#390. Change suggested by user 'swamidass'.
@Z2h-A6n
Copy link

Z2h-A6n commented Nov 23, 2022

I've started working on this in a fork: https://github.com/Z2h-A6n/proplot

I've (partially?) fixed the cmap_d deprecation and removal using the suggestion to use matplotlib.colormaps instead, but there's a probably-related issue that I haven't figured out how to solve, namely certain types of plots (I've tried ax.plot() which doesn't have this problem and ax.fill_between() which does) raise the following exception:

Traceback (most recent call last):
  File "fillbetween-example.py", line 4, in <module>
    ax.fill_between([0, 1], [0, 0], [1, 1])
  File "/usr/lib/python3.10/site-packages/proplot/internals/inputs.py", line 292, in _preprocess_or_redirect
    return func(self, *args, **kwargs)  # call unbound method
  File "/usr/lib/python3.10/site-packages/proplot/axes/plot.py", line 3337, in fill_between
    return self._apply_fill(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/proplot/axes/plot.py", line 3297, in _apply_fill
    obj = self._call_native(name, x, y1, y2, where=w, **kw)
  File "/usr/lib/python3.10/site-packages/proplot/axes/plot.py", line 1293, in _call_native
    obj = getattr(super(), name)(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/__init__.py", line 1423, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 5367, in fill_between
    return self._fill_between_x_or_y(
  File "/usr/lib/python3.10/site-packages/matplotlib/axes/_axes.py", line 5353, in _fill_between_x_or_y
    collection = mcoll.PolyCollection(polys, **kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 454, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/collections.py", line 1174, in __init__
    super().__init__(**kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/_api/deprecation.py", line 454, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/matplotlib/collections.py", line 158, in __init__
    cm.ScalarMappable.__init__(self, norm, cmap)
  File "/usr/lib/python3.10/site-packages/matplotlib/cm.py", line 415, in __init__
    self.set_cmap(cmap)  # The Colormap instance of this ScalarMappable.
  File "/usr/lib/python3.10/site-packages/matplotlib/cm.py", line 603, in set_cmap
    self.cmap = _ensure_cmap(cmap)
  File "/usr/lib/python3.10/site-packages/matplotlib/cm.py", line 741, in _ensure_cmap
    _api.check_in_list(sorted(_colormaps), cmap=cmap_name)
  File "/usr/lib/python3.10/site-packages/matplotlib/_api/__init__.py", line 131, in check_in_list
    raise ValueError(msg)
ValueError: 'Fire' is not a valid value for cmap; supported values are 'Accent', 'Accent_r', 'Blues', 'Blues_r', 'BrBG', 'BrBG_r', 'BuGn', 'BuGn_r', 'BuPu', 'BuPu_r', 'CMRmap', 'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges', 'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu', 'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r', 'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3', 'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd', 'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r', 'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag', 'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r', 'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r', 'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r', 'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow', 'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b', 'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted', 'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r'

@dforero0896
Copy link

Hi, will there be a permanent solution to this? Some time ago using the dev version seemed to work (still raising some deprecation warnings every time the code is run) but now it just doesn't work. I've tried reinstalling proplot and proplot-dev but still get the same error. I've had to remove the proplot dependency from many scripts now but I would rather not have to since it makes plotting so much easier.

Thanks in advance for any help/info.

@cvanelteren
Copy link

cvanelteren commented Jul 29, 2023

@dforero0896 I took a stab at it in #433.
Plotting seems to work again. There are no proper unittests however so I can't be sure the entire codebase works with mpl v3.8. Give it a shot if you want!

image

@dforero0896
Copy link

Hi, thanks for you comment. I've tried !pip install git+https://github.com/cvanelteren/proplot.git --user but I keep getting the same error. It seems the requirement is still mpl < 3.6.0 so it downgrades.

@cvanelteren
Copy link

@dforero0896 You need to pull from the changed branched. The command you outlined pulls from the main branch that does not have the changes. Run:

!pip install git+https://github.com/cvanelteren/[email protected] --user
from jupyter or without the ! from a terminal. Note that this does not upgrade matplotlib automatically as the code should be backwards compatible, but atleast I won't pull your mpl version down. You can upgrade mpl either before or after.

@dforero0896
Copy link

Right! I didn't notice. Thanks! I just tested it and it works like a charm so far. I'll update if I find something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants