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

Skip to content

Commit 303881d

Browse files
jklymakgreglucas
andcommitted
DOC: fix inaccuracy in colormap tutorial
Co-authored-by: Greg Lucas <[email protected]>
1 parent 861d155 commit 303881d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tutorials/colors/colormap-manipulation.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,14 @@ def plot_examples(colormaps):
132132
plot_examples([viridis, newcmp])
133133

134134
##############################################################################
135-
# We can easily reduce the dynamic range of a colormap; here we choose the
136-
# middle 0.5 of the colormap. However, we need to interpolate from a larger
137-
# colormap, otherwise the new colormap will have repeated values.
138-
139-
viridis_big = cm.get_cmap('viridis', 512)
140-
newcmp = ListedColormap(viridis_big(np.linspace(0.25, 0.75, 256)))
135+
# We can reduce the dynamic range of a colormap; here we choose the
136+
# middle half of the colormap. Note, however, that because viridis is a
137+
# listed colormap, we will end up with 128 discrete values instead of the 256
138+
# values that were in the original colormap. This method does not interpolate
139+
# in color-space to add new colors.
140+
141+
viridis_big = cm.get_cmap('viridis')
142+
newcmp = ListedColormap(viridis_big(np.linspace(0.25, 0.75, 128)))
141143
plot_examples([viridis, newcmp])
142144

143145
##############################################################################

0 commit comments

Comments
 (0)