MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / get_cmap

Method get_cmap

lib/matplotlib/cm.py:200–230  ·  view source on GitHub ↗

Return a color map specified through *cmap*. Parameters ---------- cmap : str or `~matplotlib.colors.Colormap` or None - if a `.Colormap`, return it - if a string, look it up in ``mpl.colormaps`` - if None, return the Colormap de

(self, cmap)

Source from the content-addressed store, hash-verified

198 self._cmaps.pop(name, None)
199
200 def get_cmap(self, cmap):
201 """
202 Return a color map specified through *cmap*.
203
204 Parameters
205 ----------
206 cmap : str or `~matplotlib.colors.Colormap` or None
207
208 - if a `.Colormap`, return it
209 - if a string, look it up in ``mpl.colormaps``
210 - if None, return the Colormap defined in :rc:`image.cmap`
211
212 Returns
213 -------
214 Colormap
215 """
216 # get the default color map
217 if cmap is None:
218 return self[mpl.rcParams["image.cmap"]]
219
220 # if the user passed in a Colormap, simply return it
221 if isinstance(cmap, colors.Colormap):
222 return cmap
223 if isinstance(cmap, str):
224 _api.check_in_list(sorted(_colormaps), cmap=cmap)
225 # otherwise, it must be a string so look it up
226 return self[cmap]
227 raise TypeError(
228 'get_cmap expects None or an instance of a str or Colormap . ' +
229 f'you passed {cmap!r} of type {type(cmap)}'
230 )
231
232
233# public access to the colormaps should be via `matplotlib.colormaps`. For now,

Callers 13

figure_editFunction · 0.45
on_changedMethod · 0.45
test_parentless_mappableFunction · 0.45
test_color_logicFunction · 0.45
test_colormaps_get_cmapFunction · 0.45
pie.pyFile · 0.45
plot_imshow_with_labelsFunction · 0.45
plot_quadrantsFunction · 0.45
imshow3dFunction · 0.45

Calls

no outgoing calls

Tested by 5

test_parentless_mappableFunction · 0.36
test_color_logicFunction · 0.36
test_colormaps_get_cmapFunction · 0.36