7676newcolors [:25 , :] = pink
7777newcmp = ListedColormap (newcolors )
7878
79+
7980def plot_examples (cms ):
8081 """
8182 helper function to plot two colormaps
8283 """
8384 np .random .seed (19680801 )
84- data = np .random .randn (30 ,30 )
85+ data = np .random .randn (30 , 30 )
8586
8687 fig , axs = plt .subplots (1 , 2 , figsize = (6 , 3 ), constrained_layout = True )
87- for [ax , cm ] in zip (axs , cms ):
88- psm = ax .pcolormesh (data , cmap = cm , rasterized = True , vmin = - 4 , vmax = 4 )
88+ for [ax , cmap ] in zip (axs , cms ):
89+ psm = ax .pcolormesh (data , cmap = cmap , rasterized = True , vmin = - 4 , vmax = 4 )
8990 fig .colorbar (psm , ax = ax )
9091 plt .show ()
9192
@@ -145,6 +146,7 @@ def plot_examples(cms):
145146 [0.5 , 0.0 , 0.0 ],
146147 [1.0 , 1.0 , 1.0 ]]}
147148
149+
148150def plot_linearmap (cdict ):
149151 newcmp = LinearSegmentedColormap ('testCmap' , segmentdata = cdict , N = 256 )
150152 rgba = newcmp (np .linspace (0 , 1 , 256 ))
@@ -170,9 +172,9 @@ def plot_linearmap(cdict):
170172# are both superfluous to the interpolation, which happens between the last
171173# element of the first anchor and the first element of the second anchor.
172174
173- cdict ['red' ] = [[0.0 , 0.0 , 0.3 ],
174- [0.5 , 1.0 , 0.9 ],
175- [1.0 , 1.0 , 1.0 ]]
175+ cdict ['red' ] = [[0.0 , 0.0 , 0.3 ],
176+ [0.5 , 1.0 , 0.9 ],
177+ [1.0 , 1.0 , 1.0 ]]
176178plot_linearmap (cdict )
177179
178180
0 commit comments