forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
83 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
""" | ||
Reference for colormaps included with Matplotlib. | ||
This reference example shows all colormaps included with Matplotlib. Note that | ||
any colormap listed here can be reversed by appending "_r" (e.g., "pink_r"). | ||
These colormaps are divided into the following categories: | ||
Sequential: | ||
These colormaps are approximately monochromatic colormaps varying smoothly | ||
between two color tones---usually from low saturation (e.g. white) to high | ||
saturation (e.g. a bright blue). Sequential colormaps are ideal for | ||
representing most scientific data since they show a clear progression from | ||
low-to-high values. | ||
Diverging: | ||
These colormaps have a median value (usually light in color) and vary | ||
smoothly to two different color tones at high and low values. Diverging | ||
colormaps are ideal when your data has a median value that is significant | ||
(e.g. 0, such that positive and negative values are represented by | ||
different colors of the colormap). | ||
Qualitative: | ||
These colormaps vary rapidly in color. Qualitative colormaps are useful for | ||
choosing a set of discrete colors. For example:: | ||
color_list = plt.cm.Set3(np.linspace(0, 1, 12)) | ||
gives a list of RGB colors that are good for plotting a series of lines on | ||
a dark background. | ||
Miscellaneous: | ||
Colormaps that don't fit into the categories above. | ||
""" | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
cmaps = [('Sequential', ['binary', 'Blues', 'BuGn', 'BuPu', 'gist_yarg', | ||
'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', | ||
'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', | ||
'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']), | ||
('Sequential (2)', ['afmhot', 'autumn', 'bone', 'cool', 'copper', | ||
'gist_gray', 'gist_heat', 'gray', 'hot', 'pink', | ||
'spring', 'summer', 'winter']), | ||
('Diverging', ['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', | ||
'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'seismic']), | ||
('Qualitative', ['Accent', 'Dark2', 'hsv', 'Paired', 'Pastel1', | ||
'Pastel2', 'Set1', 'Set2', 'Set3', 'spectral']), | ||
('Miscellaneous', ['gist_earth', 'gist_ncar', 'gist_rainbow', | ||
'gist_stern', 'jet', 'brg', 'CMRmap', 'cubehelix', | ||
'gnuplot', 'gnuplot2', 'ocean', 'rainbow', | ||
'terrain', 'flag', 'prism'])] | ||
|
||
|
||
nrows = max(len(cmap_list) for cmap_category, cmap_list in cmaps) | ||
gradient = np.linspace(0, 1, 256) | ||
gradient = np.vstack((gradient, gradient)) | ||
|
||
def plot_color_gradients(cmap_category, cmap_list): | ||
fig, axes = plt.subplots(nrows=nrows) | ||
fig.subplots_adjust(top=0.95, bottom=0.01, left=0.2, right=0.99) | ||
axes[0].set_title(cmap_category + ' colormaps', fontsize=14) | ||
|
||
for ax, name in zip(axes, cmap_list): | ||
ax.imshow(gradient, aspect='auto', cmap=plt.get_cmap(name)) | ||
pos = list(ax.get_position().bounds) | ||
x_text = pos[0] - 0.01 | ||
y_text = pos[1] + pos[3]/2. | ||
fig.text(x_text, y_text, name, va='center', ha='right', fontsize=10) | ||
|
||
# Turn off *all* ticks & spines, not just the ones with colormaps. | ||
for ax in axes: | ||
ax.set_axis_off() | ||
|
||
for cmap_category, cmap_list in cmaps: | ||
plot_color_gradients(cmap_category, cmap_list) | ||
|
||
plt.show() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.