Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit54d24df

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 parent5c45952 commit54d24df

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
importnumpyasnp
1616
importmatplotlib.pyplotasplt
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
forcmap_category,cmap_listincmaps:
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)

[8]ページ先頭

©2009-2025 Movatter.jp