MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / get_cmap

Function get_cmap

site-packages/matplotlib/cm.py:154–182  ·  view source on GitHub ↗

Get a colormap instance, defaulting to rc values if *name* is None. Colormaps added with :func:`register_cmap` take precedence over built-in colormaps. If *name* is a :class:`matplotlib.colors.Colormap` instance, it will be returned. If *lut* is not None it must be an int

(name=None, lut=None)

Source from the content-addressed store, hash-verified

152
153
154def get_cmap(name=None, lut=None):
155 """
156 Get a colormap instance, defaulting to rc values if *name* is None.
157
158 Colormaps added with :func:`register_cmap` take precedence over
159 built-in colormaps.
160
161 If *name* is a :class:`matplotlib.colors.Colormap` instance, it will be
162 returned.
163
164 If *lut* is not None it must be an integer giving the number of
165 entries desired in the lookup table, and *name* must be a standard
166 mpl colormap name.
167 """
168 if name is None:
169 name = mpl.rcParams['image.cmap']
170
171 if isinstance(name, colors.Colormap):
172 return name
173
174 if name in cmap_d:
175 if lut is None:
176 return cmap_d[name]
177 else:
178 return cmap_d[name]._resample(lut)
179 else:
180 raise ValueError(
181 "Colormap %s is not recognized. Possible values are: %s"
182 % (name, ', '.join(sorted(cmap_d))))
183
184
185class ScalarMappable(object):

Callers 4

_get_cmap_normsFunction · 0.90
__init__Method · 0.85
set_cmapMethod · 0.85

Calls 2

_resampleMethod · 0.45
joinMethod · 0.45

Tested by 2

_get_cmap_normsFunction · 0.72