|
1 | | -Colormap registry |
2 | | ------------------- |
| 1 | +Colormap registry (experimental) |
| 2 | +-------------------------------- |
3 | 3 |
|
4 | | -Colormaps are now managed via `matplotlib.colormaps`, which is a |
5 | | -`.ColormapRegistry`. |
| 4 | +Colormaps are now managed via `matplotlib.colormaps` (or `.pyplot.colormaps`), |
| 5 | +which is a `.ColormapRegistry`. While we are confident that the API is final, |
| 6 | +we formally mark it as experimental for 3.5 because we want to keep the option |
| 7 | +to still adapt the API for 3.6 should the need arise. |
6 | 8 |
|
7 | 9 | Colormaps can be obtained using item access:: |
8 | 10 |
|
9 | | - import matplotlib asmpl |
10 | | - cmap =mpl.colormaps['viridis'] |
| 11 | + import matplotlib.pyplot asplt |
| 12 | + cmap =plt.colormaps['viridis'] |
11 | 13 |
|
12 | 14 | To register new colormaps use:: |
13 | 15 |
|
14 | | -mpl.colormaps.register(my_colormap) |
| 16 | +plt.colormaps.register(my_colormap) |
15 | 17 |
|
16 | | -The use of `matplotlib.cm.get_cmap` and `matplotlib.cm.register_cmap` is |
17 | | -discouraged in favor of the above. Within `.pyplot` the use of |
18 | | -``plt.get_cmap()`` and ``plt.register_cmap()`` will continue to be supported. |
| 18 | +We recommend to use the new API instead of the `~.cm.get_cmap` and |
| 19 | +`~.cm.register_cmap` functions for new code. `matplotlib.cm.get_cmap` and |
| 20 | +`matplotlib.cm.register_cmap` will eventually be deprecated and removed. |
| 21 | +Within `.pyplot` ``plt.get_cmap()`` and ``plt.register_cmap()`` will continue |
| 22 | +to be supported for backward compatibility. |