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

Function _gen_cmap_registry

lib/matplotlib/cm.py:32–63  ·  view source on GitHub ↗

Generate a dict mapping standard colormap names to standard colormaps, as well as the reversed colormaps.

()

Source from the content-addressed store, hash-verified

30
31
32def _gen_cmap_registry():
33 """
34 Generate a dict mapping standard colormap names to standard colormaps, as
35 well as the reversed colormaps.
36 """
37 cmap_d = {**cmaps_listed}
38 for name, spec in datad.items():
39 cmap_d[name] = ( # Precache the cmaps at a fixed lutsize..
40 colors.LinearSegmentedColormap(name, spec, _LUTSIZE)
41 if 'red' in spec else
42 colors.ListedColormap(spec['listed'], name)
43 if 'listed' in spec else
44 colors.LinearSegmentedColormap.from_list(name, spec, _LUTSIZE))
45
46 # Register colormap aliases for gray and grey.
47 aliases = {
48 # alias -> original name
49 'grey': 'gray',
50 'gist_grey': 'gist_gray',
51 'gist_yerg': 'gist_yarg',
52 'Grays': 'Greys',
53 }
54 for alias, original_name in aliases.items():
55 cmap = cmap_d[original_name].copy()
56 cmap.name = alias
57 cmap_d[alias] = cmap
58
59 # Generate reversed cmaps.
60 for cmap in list(cmap_d.values()):
61 rmap = cmap.reversed()
62 cmap_d[rmap.name] = rmap
63 return cmap_d
64
65
66class ColormapRegistry(Mapping):

Callers 1

cm.pyFile · 0.85

Calls 4

from_listMethod · 0.80
valuesMethod · 0.80
copyMethod · 0.45
reversedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…