Get a colormap instance, defaulting to rc values if *name* is None. Parameters ---------- name : `~matplotlib.colors.Colormap` or str or None, default: None If a `.Colormap` instance, it will be returned. Otherwise, the name of a colormap known to Matplotlib, which
(name: Colormap | str | None = None, lut: int | None = None)
| 2705 | |
| 2706 | |
| 2707 | def get_cmap(name: Colormap | str | None = None, lut: int | None = None) -> Colormap: |
| 2708 | """ |
| 2709 | Get a colormap instance, defaulting to rc values if *name* is None. |
| 2710 | |
| 2711 | Parameters |
| 2712 | ---------- |
| 2713 | name : `~matplotlib.colors.Colormap` or str or None, default: None |
| 2714 | If a `.Colormap` instance, it will be returned. Otherwise, the name of |
| 2715 | a colormap known to Matplotlib, which will be resampled by *lut*. The |
| 2716 | default, None, means :rc:`image.cmap`. |
| 2717 | lut : int or None, default: None |
| 2718 | If *name* is not already a Colormap instance and *lut* is not None, the |
| 2719 | colormap will be resampled to have *lut* entries in the lookup table. |
| 2720 | |
| 2721 | Returns |
| 2722 | ------- |
| 2723 | Colormap |
| 2724 | """ |
| 2725 | if name is None: |
| 2726 | name = rcParams['image.cmap'] |
| 2727 | if isinstance(name, Colormap): |
| 2728 | return name |
| 2729 | _api.check_in_list(sorted(_colormaps), name=name) |
| 2730 | if lut is None: |
| 2731 | return _colormaps[name] |
| 2732 | else: |
| 2733 | return _colormaps[name].resampled(lut) |
| 2734 | |
| 2735 | |
| 2736 | def set_cmap(cmap: Colormap | str) -> None: |