Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b51f6d3

Browse files
committed
added a reversing section
1 parent 5c45952 commit b51f6d3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

examples/color/colormap_reference.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
66
Reference for colormaps included with Matplotlib.
77
8-
A reversed version of each of these colormaps is available by appending
9-
``_r`` to the name, e.g., ``viridis_r``.
10-
118
See :doc:`/tutorials/colors/colormaps` for an in-depth discussion about
129
colormaps, including colorblind-friendliness.
1310
"""
1411

1512
import numpy as np
1613
import matplotlib.pyplot as plt
1714

18-
1915
cmaps = [('Perceptually Uniform Sequential', [
2016
'viridis', 'plasma', 'inferno', 'magma', 'cividis']),
2117
('Sequential', [
@@ -40,7 +36,6 @@
4036
'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral',
4137
'gist_ncar'])]
4238

43-
4439
gradient = np.linspace(0, 1, 256)
4540
gradient = np.vstack((gradient, gradient))
4641

@@ -67,7 +62,17 @@ def plot_color_gradients(cmap_category, cmap_list):
6762
for cmap_category, cmap_list in cmaps:
6863
plot_color_gradients(cmap_category, cmap_list)
6964

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'])
7176

7277
#############################################################################
7378
#

0 commit comments

Comments
 (0)