11'''
2- Show what matplotlib colormaps look like in grayscale.
2+ ==================================
3+ Grayscale version of the colormaps
4+ ==================================
5+
6+ Show what Matplotlib colormaps look like in grayscale.
37Uses lightness L* as a proxy for grayscale value.
48'''
59
6- from colormaps import cmaps
7-
8- #from skimage import color
9- # we are using a local copy of colorconv from scikit-image to reduce dependencies.
10- # You should probably use the one from scikit-image in most cases.
1110import numpy as np
11+ import matplotlib as mpl
1212import matplotlib .pyplot as plt
1313from matplotlib import cm
14- import matplotlib as mpl
1514from colorspacious import cspace_converter
15+ from colormaps import cmaps # the colormaps, grouped by category
1616
1717mpl .rcParams .update ({'font.size' : 14 })
1818
19-
20- # indices to step through colormap
19+ # Indices to step through colormap.
2120x = np .linspace (0.0 , 1.0 , 100 )
2221
23- # nrows = max(len(cmap_list) for cmap_category, cmap_list in cmaps)
2422gradient = np .linspace (0 , 1 , 256 )
2523gradient = np .vstack ((gradient , gradient ))
2624
25+
2726def plot_color_gradients (cmap_category , cmap_list ):
28- nrows = len (cmap_list )
29- fig , axes = plt .subplots (nrows = nrows , ncols = 2 )
27+ fig , axes = plt .subplots (nrows = len (cmap_list ), ncols = 2 )
3028 fig .subplots_adjust (top = 0.95 , bottom = 0.01 , left = 0.2 , right = 0.99 ,
3129 wspace = 0.05 )
3230 fig .suptitle (cmap_category + ' colormaps' , fontsize = 14 , y = 1.0 , x = 0.6 )
3331
3432 for ax , name in zip (axes , cmap_list ):
3533
36- # Get rgb values for colormap
34+ # Get RGB values for colormap.
3735 rgb = cm .get_cmap (plt .get_cmap (name ))(x )[np .newaxis ,:,:3 ]
3836
3937 # Get colormap in CAM02-UCS colorspace. We want the lightness.
@@ -49,9 +47,9 @@ def plot_color_gradients(cmap_category, cmap_list):
4947 fig .text (x_text , y_text , name , va = 'center' , ha = 'right' , fontsize = 10 )
5048
5149 # Turn off *all* ticks & spines, not just the ones with colormaps.
52- for ax in axes :
53- ax [ 0 ] .set_axis_off ()
54- ax [ 1 ]. set_axis_off ()
50+ for ax in axes . flat :
51+ ax .set_axis_off ()
52+
5553 plt .show ()
5654
5755
0 commit comments