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

Skip to content

Commit 5696953

Browse files
committed
DOC: fix inaccuracy in colormap tutorial
1 parent 861d155 commit 5696953

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tutorials/colors/colormap-manipulation.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ 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.
135+
# We can reduce the dynamic range of a colormap; here we choose the
136+
# middle 0.5 of the colormap. Note, however, that because viridis is a
137+
# listed colormap, some colors will be repeated when doing the nearest-neighbour
138+
# interpolation
138139

139-
viridis_big = cm.get_cmap('viridis', 512)
140-
newcmp = ListedColormap(viridis_big(np.linspace(0.25, 0.75, 256)))
140+
viridis_big = cm.get_cmap('viridis', 256)
141+
newcmp = ListedColormap(viridis_big(np.linspace(0.25, 0.75, 128)))
141142
plot_examples([viridis, newcmp])
142143

143144
##############################################################################

0 commit comments

Comments
 (0)