|
1 | 1 | ''' |
2 | | -For each colormap, plot the lightness parameter L* from CIELAB colorspace |
3 | | -along the y axis vs index through the colormap. Colormaps are examined in |
| 2 | +For each colormap, plot the lightness parameter L* from CIELAB colorspace |
| 3 | +along the y axis vs index through the colormap. Colormaps are examined in |
4 | 4 | categories as in the original matplotlib gallery of colormaps. |
5 | 5 | ''' |
6 | 6 |
|
7 | 7 | import colorconv as color |
| 8 | +from colormaps import cmaps |
8 | 9 | #from skimage import color |
9 | 10 | # we are using a local copy of colorconv from scikit-image to |
10 | 11 | # reduce dependencies. |
11 | | -# You should probably use the one from scikit-image in most cases. |
| 12 | +# You should probably use the one from scikit-image in most cases. |
12 | 13 | import numpy as np |
13 | 14 | import matplotlib.pyplot as plt |
14 | 15 | from matplotlib import cm |
|
26 | 27 | mpl.rcParams['mathtext.sf'] = 'sans' |
27 | 28 | mpl.rcParams['mathtext.fallback_to_cm'] = 'True' |
28 | 29 |
|
29 | | -# Have colormaps separated into categories: |
30 | | -# http://matplotlib.org/examples/color/colormaps_reference.html |
31 | | - |
32 | | -cmaps = [('Sequential', ['Blues', 'BuGn', 'BuPu', |
33 | | - 'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', |
34 | | - 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', |
35 | | - 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']), |
36 | | - ('Sequential (2)', ['afmhot', 'autumn', 'bone', 'cool', 'copper', |
37 | | - 'gist_heat', 'gray', 'hot', 'inferno', 'magma', |
38 | | - 'pink', 'plasma', 'spring', 'summer', 'viridis', |
39 | | - 'winter']), |
40 | | - ('Diverging', ['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', |
41 | | - 'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', |
42 | | - 'seismic']), |
43 | | - ('Qualitative', ['Accent', 'Dark2', 'Paired', 'Pastel1', |
44 | | - 'Pastel2', 'Set1', 'Set2', 'Set3']), |
45 | | - ('Miscellaneous', ['gist_earth', 'terrain', 'ocean', 'gist_stern', |
46 | | - 'brg', 'CMRmap', 'cubehelix', |
47 | | - 'gnuplot', 'gnuplot2', 'gist_ncar', |
48 | | - 'nipy_spectral', 'jet', 'rainbow', |
49 | | - 'gist_rainbow', 'hsv', 'flag', 'prism'])] |
50 | | - |
51 | 30 | # indices to step through colormap |
52 | 31 | x = np.linspace(0.0, 1.0, 100) |
53 | 32 |
|
|
84 | 63 | # Do separately for each category so each plot can be pretty |
85 | 64 | # to make scatter markers change color along plot: |
86 | 65 | # http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable |
87 | | - if cmap_category=='Sequential': |
| 66 | + if cmap_category=='Perceptually Uniform Sequential': |
| 67 | + dc = 1.15 # spacing between colormaps |
| 68 | + ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap, |
| 69 | + s=300, linewidths=0.) |
| 70 | + if i==2: |
| 71 | + ax.axis([-0.1,4.1,0,100]) |
| 72 | + else: |
| 73 | + ax.axis([-0.1,4.7,0,100]) |
| 74 | + locs.append(x[-1]+j*dc) # store locations for colormap labels |
| 75 | + |
| 76 | + elif cmap_category=='Sequential': |
88 | 77 | dc = 0.6 # spacing between colormaps |
89 | 78 | ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap + '_r', |
90 | 79 | s=300, linewidths=0.) |
|
0 commit comments