6
6
Reference for colormaps included with Matplotlib.
7
7
8
8
A reversed version of each of these colormaps is available by appending
9
- ``_r`` to the name, e.g., ``viridis_r` `.
9
+ ``_r`` to the name, as shown in :ref:`reverse-cmap `.
10
10
11
11
See :doc:`/tutorials/colors/colormaps` for an in-depth discussion about
12
12
colormaps, including colorblind-friendliness.
15
15
import numpy as np
16
16
import matplotlib .pyplot as plt
17
17
18
-
19
18
cmaps = [('Perceptually Uniform Sequential' , [
20
19
'viridis' , 'plasma' , 'inferno' , 'magma' , 'cividis' ]),
21
20
('Sequential' , [
40
39
'gist_rainbow' , 'rainbow' , 'jet' , 'turbo' , 'nipy_spectral' ,
41
40
'gist_ncar' ])]
42
41
43
-
44
42
gradient = np .linspace (0 , 1 , 256 )
45
43
gradient = np .vstack ((gradient , gradient ))
46
44
@@ -67,7 +65,15 @@ def plot_color_gradients(cmap_category, cmap_list):
67
65
for cmap_category , cmap_list in cmaps :
68
66
plot_color_gradients (cmap_category , cmap_list )
69
67
70
- plt .show ()
68
+
69
+ ###############################################################################
70
+ # .. _reverse-cmap:
71
+ # Reversing a colormap
72
+ # --------------------
73
+ #
74
+ # A colormap can be reversed by appending ``_r`` to the name. For example:
75
+
76
+ plot_color_gradients ("Original and reversed " , ['viridis' , 'viridis_r' ])
71
77
72
78
#############################################################################
73
79
#
0 commit comments