Skip to content

Commit

Permalink
Deprecation of the top-level cmap registration and access functions i…
Browse files Browse the repository at this point in the history
…n mpl.cm
  • Loading branch information
jcesardasilva authored and daurer committed Jul 17, 2024
1 parent fcadc38 commit af15a27
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ptypy/utils/plot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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():
"""\
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit af15a27

Please sign in to comment.