Generate a dict mapping standard colormap names to standard colormaps, as well as the reversed colormaps.
()
| 30 | |
| 31 | |
| 32 | def _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 | |
| 66 | class ColormapRegistry(Mapping): |