| 
14 | 14 | import matplotlib.pyplot as plt  | 
15 | 15 | from matplotlib import cm  | 
16 | 16 | import matplotlib as mpl  | 
 | 17 | +from colorspacious import cspace_converter  | 
17 | 18 | 
 
  | 
18 | 19 | mpl.rcParams.update({'font.size': 12})  | 
19 | 20 | 
 
  | 
 | 
46 | 47 |             # Get rgb values for colormap  | 
47 | 48 |             rgb = cm.get_cmap(cmap)(x)[np.newaxis,:,:3]  | 
48 | 49 | 
 
  | 
49 |  | -            # Get colormap in CIE LAB. We want the L here.  | 
50 |  | -            lab = color.rgb2lab(rgb)  | 
 | 50 | +            # Get colormap in CAM02-UCS colorspace. We want the lightness.  | 
 | 51 | +            lab = cspace_converter("sRGB1", "CAM02-UCS")(rgb)  | 
51 | 52 | 
 
  | 
52 | 53 |             # Plot colormap L values  | 
53 | 54 |             # Do separately for each category so each plot can be pretty  | 
54 | 55 |             # to make scatter markers change color along plot:  | 
55 | 56 |             # http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable  | 
56 | 57 |             if cmap_category=='Perceptually Uniform Sequential':  | 
57 | 58 |                 dc = 1.15 # spacing between colormaps  | 
58 |  | -                ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap,  | 
 | 59 | +                ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap,  | 
59 | 60 |                            s=300, linewidths=0.)  | 
60 | 61 |                 if i==2:  | 
61 | 62 |                     ax.axis([-0.1,4.1,0,100])  | 
 | 
65 | 66 | 
 
  | 
66 | 67 |             elif cmap_category=='Sequential':  | 
67 | 68 |                 dc = 0.6 # spacing between colormaps  | 
68 |  | -                ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap + '_r',  | 
 | 69 | +                # These colormaps all start at high lightness but we want them  | 
 | 70 | +                # reversed to look nice in the plot, so reverse the order.  | 
 | 71 | +                ax.scatter(x+j*dc, lab[0,::-1,0], c=x[::-1], cmap=cmap,  | 
69 | 72 |                            s=300, linewidths=0.)  | 
70 | 73 |                 if i==2:  | 
71 | 74 |                     ax.axis([-0.1,4.1,0,100])  | 
 | 
0 commit comments