Skip to content

Commit 54d24df

Browse files
story645jklymaktimhoffm
committed
added a reversing section
Co-authored-by: Jody Klymak <jklymak@gmail.com> Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
1 parent 5c45952 commit 54d24df

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

examples/color/colormap_reference.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Reference for colormaps included with Matplotlib.
77
88
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`.
1010
1111
See :doc:`/tutorials/colors/colormaps` for an in-depth discussion about
1212
colormaps, including colorblind-friendliness.
@@ -15,7 +15,6 @@
1515
import numpy as np
1616
import matplotlib.pyplot as plt
1717

18-
1918
cmaps = [('Perceptually Uniform Sequential', [
2019
'viridis', 'plasma', 'inferno', 'magma', 'cividis']),
2120
('Sequential', [
@@ -40,7 +39,6 @@
4039
'gist_rainbow', 'rainbow', 'jet', 'turbo', 'nipy_spectral',
4140
'gist_ncar'])]
4241

43-
4442
gradient = np.linspace(0, 1, 256)
4543
gradient = np.vstack((gradient, gradient))
4644

@@ -67,7 +65,15 @@ def plot_color_gradients(cmap_category, cmap_list):
6765
for 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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy