205
205
206
206
207
207
def plot_color_gradients (cmap_category , cmap_list , nrows ):
208
- fig , axes = plt .subplots (nrows = nrows )
208
+ fig , axs = plt .subplots (nrows = nrows )
209
209
fig .subplots_adjust (top = 0.95 , bottom = 0.01 , left = 0.2 , right = 0.99 )
210
- axes [0 ].set_title (cmap_category + ' colormaps' , fontsize = 14 )
210
+ axs [0 ].set_title (cmap_category + ' colormaps' , fontsize = 14 )
211
211
212
- for ax , name in zip (axes , cmap_list ):
212
+ for ax , name in zip (axs , cmap_list ):
213
213
ax .imshow (gradient , aspect = 'auto' , cmap = plt .get_cmap (name ))
214
214
pos = list (ax .get_position ().bounds )
215
215
x_text = pos [0 ] - 0.01
216
216
y_text = pos [1 ] + pos [3 ]/ 2.
217
217
fig .text (x_text , y_text , name , va = 'center' , ha = 'right' , fontsize = 10 )
218
218
219
219
# Turn off *all* ticks & spines, not just the ones with colormaps.
220
- for ax in axes :
220
+ for ax in axs :
221
221
ax .set_axis_off ()
222
222
223
223
@@ -258,10 +258,10 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
258
258
nsubplots = int (np .ceil (len (cmap_list ) / dsub ))
259
259
260
260
# squeeze=False to handle similarly the case of a single subplot
261
- fig , axes = plt .subplots (nrows = nsubplots , squeeze = False ,
262
- figsize = (7 , 2.6 * nsubplots ))
261
+ fig , axs = plt .subplots (nrows = nsubplots , squeeze = False ,
262
+ figsize = (7 , 2.6 * nsubplots ))
263
263
264
- for i , ax in enumerate (axes .flat ):
264
+ for i , ax in enumerate (axs .flat ):
265
265
266
266
locs = [] # locations for text labels
267
267
@@ -300,7 +300,7 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
300
300
# Set up the axis limits:
301
301
# * the 1st subplot is used as a reference for the x-axis limits
302
302
# * lightness values goes from 0 to 100 (y-axis limits)
303
- ax .set_xlim (axes [0 , 0 ].get_xlim ())
303
+ ax .set_xlim (axs [0 , 0 ].get_xlim ())
304
304
ax .set_ylim (0.0 , 100.0 )
305
305
306
306
# Set up labels for colormaps
@@ -364,12 +364,12 @@ def plot_color_gradients(cmap_category, cmap_list, nrows):
364
364
365
365
366
366
def plot_color_gradients (cmap_category , cmap_list ):
367
- fig , axes = plt .subplots (nrows = len (cmap_list ), ncols = 2 )
367
+ fig , axs = plt .subplots (nrows = len (cmap_list ), ncols = 2 )
368
368
fig .subplots_adjust (top = 0.95 , bottom = 0.01 , left = 0.2 , right = 0.99 ,
369
369
wspace = 0.05 )
370
370
fig .suptitle (cmap_category + ' colormaps' , fontsize = 14 , y = 1.0 , x = 0.6 )
371
371
372
- for ax , name in zip (axes , cmap_list ):
372
+ for ax , name in zip (axs , cmap_list ):
373
373
374
374
# Get RGB values for colormap.
375
375
rgb = cm .get_cmap (plt .get_cmap (name ))(x )[np .newaxis , :, :3 ]
@@ -387,7 +387,7 @@ def plot_color_gradients(cmap_category, cmap_list):
387
387
fig .text (x_text , y_text , name , va = 'center' , ha = 'right' , fontsize = 10 )
388
388
389
389
# Turn off *all* ticks & spines, not just the ones with colormaps.
390
- for ax in axes .flat :
390
+ for ax in axs .flat :
391
391
ax .set_axis_off ()
392
392
393
393
plt .show ()
0 commit comments