File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -132,12 +132,14 @@ def plot_examples(colormaps):
132132plot_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 )))
141143plot_examples ([viridis , newcmp ])
142144
143145##############################################################################
You can’t perform that action at this time.
0 commit comments