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