Set the default colormap. Applies to the current image if any. See help(colormaps) for more information. *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or the name of a registered colormap. See :func:`matplotlib.cm.register_cmap` and :func:`matplotlib.cm.
(cmap)
| 2128 | |
| 2129 | |
| 2130 | def set_cmap(cmap): |
| 2131 | """ |
| 2132 | Set the default colormap. Applies to the current image if any. |
| 2133 | See help(colormaps) for more information. |
| 2134 | |
| 2135 | *cmap* must be a :class:`~matplotlib.colors.Colormap` instance, or |
| 2136 | the name of a registered colormap. |
| 2137 | |
| 2138 | See :func:`matplotlib.cm.register_cmap` and |
| 2139 | :func:`matplotlib.cm.get_cmap`. |
| 2140 | """ |
| 2141 | cmap = cm.get_cmap(cmap) |
| 2142 | |
| 2143 | rc('image', cmap=cmap.name) |
| 2144 | im = gci() |
| 2145 | |
| 2146 | if im is not None: |
| 2147 | im.set_cmap(cmap) |
| 2148 | |
| 2149 | |
| 2150 | @docstring.copy_dedent(matplotlib.image.imread) |