66Reference for colormaps included with Matplotlib.
77
88A 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 `.
1010
1111See :doc:`/tutorials/colors/colormaps` for an in-depth discussion about
1212colormaps, including colorblind-friendliness.
1515import numpy as np
1616import matplotlib .pyplot as plt
1717
18-
1918cmaps = [('Perceptually Uniform Sequential' , [
2019 'viridis' , 'plasma' , 'inferno' , 'magma' , 'cividis' ]),
2120 ('Sequential' , [
4039 'gist_rainbow' , 'rainbow' , 'jet' , 'turbo' , 'nipy_spectral' ,
4140 'gist_ncar' ])]
4241
43-
4442gradient = np .linspace (0 , 1 , 256 )
4543gradient = np .vstack ((gradient , gradient ))
4644
@@ -67,7 +65,15 @@ def plot_color_gradients(cmap_category, cmap_list):
6765for cmap_category , cmap_list in cmaps :
6866 plot_color_gradients (cmap_category , cmap_list )
6967
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' ])
7177
7278#############################################################################
7379#
0 commit comments