From dd65a78ea39117c94c90ce6a22c7ff89f435c302 Mon Sep 17 00:00:00 2001 From: Julio Cesar da Silva Date: Wed, 17 Jul 2024 17:46:37 +0200 Subject: [PATCH] Deprecation of the top-level cmap registration and access functions in mpl.cm (#555) --- ptypy/utils/plot_utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ptypy/utils/plot_utils.py b/ptypy/utils/plot_utils.py index 398b8d746..2f85e72b5 100644 --- a/ptypy/utils/plot_utils.py +++ b/ptypy/utils/plot_utils.py @@ -345,7 +345,7 @@ def imsave(a, filename=None, vmin=None, vmax=None, cmap=None): uses a matplotlib colormap with name 'gray' """ if str(cmap) == cmap: - cmap = mpl.cm.get_cmap(cmap) + cmap = mpl.colormaps.get_cmap(cmap) if a.dtype.kind == 'c': i = complex2rgb(a, vmin=vmin, vmax=vmax) @@ -379,7 +379,7 @@ def imload(filename): # Removing it due to DeprecationWarning in Matplotlib # DeprecationWarning: Passing raw data via parameters data and lut to register_cmap() is deprecated since 3.3 and will become an error two minor releases later. Instead use: register_cmap(cmap=LinearSegmentedColormap(name, data, lut)) # Franz map -# mpl.cm.register_cmap(name='franzmap', data={'red': ((0.000, 0, 0), +# mpl.colormaps.register_cmap(name='franzmap', data={'red': ((0.000, 0, 0), # (0.350, 0, 0), # (0.660, 1, 1), # (0.890, 1, 1), @@ -416,7 +416,7 @@ def imload(filename): (0.650, 0, 0), (1.000, 0, 0))} -mpl.cm.register_cmap(cmap=LinearSegmentedColormap(name='franzmap', segmentdata=franzmap_cm, N=256)) +mpl.colormaps.register(cmap=LinearSegmentedColormap(name='franzmap', segmentdata=franzmap_cm, N=256)) def franzmap(): """\ @@ -679,10 +679,10 @@ def set_channel(self, channel, update=True): def set_cmap(self, cmap, update=True): try: - self.cmap = mpl.cm.get_cmap(cmap) + self.cmap = mpl.colormaps.get_cmap(cmap) except: logger.debug("Colormap `%s` not found. Using `gray`" % str(cmap)) - self.cmap = mpl.cm.get_cmap('gray') + self.cmap = mpl.colormaps.get_cmap('gray') if update: self._update() self._update_colorscale()