proplot icon indicating copy to clipboard operation
proplot copied to clipboard

Proplot not compatible with matplotlib 3.6

Open swamidass opened this issue 2 years ago • 14 comments

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.

swamidass avatar Sep 20 '22 18:09 swamidass

Could you try the newest version of proplot?

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

zxdawn avatar Sep 21 '22 01:09 zxdawn

@zxdawn works for me

cvanelteren avatar Sep 21 '22 12:09 cvanelteren

That worked. Perhaps push a release to pypi?

swamidass avatar Sep 24 '22 05:09 swamidass

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...

ForceBru avatar Oct 21 '22 19:10 ForceBru

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 avatar Nov 08 '22 00:11 knaaptime

(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' )

knaaptime avatar Nov 08 '22 00:11 knaaptime

@knaaptime Yes, that's caused by https://github.com/matplotlib/matplotlib/pull/22298.

zxdawn avatar Nov 08 '22 12:11 zxdawn

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

knaaptime avatar Nov 10 '22 18:11 knaaptime

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'

Z2h-A6n avatar Nov 23 '22 22:11 Z2h-A6n

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.

dforero0896 avatar Jul 25 '23 19:07 dforero0896

@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

cvanelteren avatar Jul 29 '23 15:07 cvanelteren

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.

dforero0896 avatar Aug 01 '23 21:08 dforero0896

@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.

cvanelteren avatar Aug 02 '23 06:08 cvanelteren

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.

dforero0896 avatar Aug 02 '23 12:08 dforero0896