|
| 1 | +""" |
| 2 | +Reference for "sequential" colormaps. |
| 3 | +
|
| 4 | +Sequential colormaps are approximately monochromatic colormaps going from low |
| 5 | +saturation (e.g. white) to high saturation (e.g. a bright blue). Sequential |
| 6 | +colormaps are ideal for representing most scientific data since they show |
| 7 | +a clear progression from low-to-high values. |
| 8 | +""" |
| 9 | +import numpy as np |
| 10 | +import matplotlib.pyplot as plt |
| 11 | + |
| 12 | + |
| 13 | +gradient = np.linspace(0, 1, 256) |
| 14 | +gradient = np.vstack((gradient, gradient)) |
| 15 | + |
| 16 | +# Note that any of these colormaps can be reversed by appending '_r'. |
| 17 | +cmaps = ['binary', 'Blues', 'BuGn', 'BuPu', 'gist_yarg', 'GnBu', 'Greens', |
| 18 | + 'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', |
| 19 | + 'RdPu', 'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd'] |
| 20 | + |
| 21 | +fig, axes = plt.subplots(nrows=len(cmaps)) |
| 22 | +fig.subplots_adjust(top=0.99, bottom=0.01, left=0.2, right=0.99) |
| 23 | + |
| 24 | +for ax, m in zip(axes, cmaps): |
| 25 | + ax.set_axis_off() |
| 26 | + ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(m)) |
| 27 | + pos = list(ax.get_position().bounds) |
| 28 | + x_text = pos[0] - 0.01 |
| 29 | + y_text = pos[1] + pos[3]/2. |
| 30 | + fig.text(x_text, y_text, m, va='center', ha='right') |
| 31 | + |
| 32 | +plt.show() |
0 commit comments