Skip to content

Proplot not compatible with matplotlib 3.6 #390

Open

Description

@swamidass

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.

Activity

  1. zxdawn commented on Sep 21, 2022

    @zxdawn

    Could you try the newest version of proplot?

    pip install git+https://github.com/proplot-dev/proplot.git
    
  2. cvanelteren commented on Sep 21, 2022

    @cvanelteren

    @zxdawn works for me

  3. swamidass commented on Sep 24, 2022

    @swamidass
    Author

    That worked. Perhaps push a release to pypi?

  4. ForceBru commented on Oct 21, 2022

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

  5. knaaptime commented on Nov 8, 2022

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

  6. knaaptime commented on Nov 8, 2022

    @knaaptime
    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' )

  7. zxdawn commented on Nov 8, 2022

    @zxdawn
  8. knaaptime commented on Nov 10, 2022

    @knaaptime
    Contributor

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

  9. Z2h-A6n commented on Nov 23, 2022

    @Z2h-A6n

    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'
    
  10. dforero0896 commented on Jul 25, 2023

    @dforero0896

    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.

  11. cvanelteren commented on Jul 29, 2023

    @cvanelteren

    @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

  12. dforero0896 commented on Aug 1, 2023

    @dforero0896

    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.

  13. cvanelteren commented on Aug 2, 2023

    @cvanelteren

    @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/proplot.git@mpl3.8 --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.

  14. dforero0896 commented on Aug 2, 2023

    @dforero0896

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions