8000 Update colormap usage documentation to prioritize string colormap names · matplotlib/matplotlib@d3ee967 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3ee967

Browse files
committed
Update colormap usage documentation to prioritize string colormap names
1 parent 61995ee commit d3ee967

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

doc/users/next_whats_new/diverging_colormaps.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ They are dark-mode diverging colormaps, with minimum lightness at the center,
66
and maximum at the extremes. These are taken from F. Crameri's Scientific
77
colour maps version 8.0.1 (DOI: https://doi.org/10.5281/zenodo.1243862).
88

9+
.. note::
10+
For `cmap` arguments, we recommend using string colormap names (e.g., `cmap="berlin"`).
11+
This is both readable and concise. If an explicit colormap instance is needed, use
12+
`plt.colormaps["berlin"]`. The `plt.cm.*` syntax is less scalable, as it only supports
13+
built-in colormaps and not user-registered ones.
914

1015
.. plot::
1116
:include-source: true
@@ -19,6 +24,6 @@ colour maps version 8.0.1 (DOI: https://doi.org/10.5281/zenodo.1243862).
1924
img = np.sin(x*y)
2025

2126
_, ax = plt.subplots(1, 3)
22-
ax[0].imshow(img, cmap=plt.cm.berlin)
23-
ax[1].imshow(img, cmap=plt.cm.managua)
24-
ax[2].imshow(img, cmap=plt.cm.vanimo)
27+
ax[0].imshow(img, cmap="berlin")
28+
ax[1].imshow(img, cmap="managua")
29+
ax[2].imshow(img, cmap="vanimo")

0 commit comments

Comments
 (0)
0