-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
DOC Added the colormap references back #9530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
DOC Added the colormap references back
- Loading branch information
commit eaefc1391fb1665c247bccae61cf95666d9926e1
There are no files selected for viewing
This file contains hidden or 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,94 @@ | ||
""" | ||
================== | ||
Colormap reference | ||
================== | ||
|
||
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 | ||
|
||
|
||
# Have colormaps separated into categories: | ||
# http://matplotlib.org/examples/color/colormaps_reference.html | ||
cmaps = [('Perceptually Uniform Sequential', [ | ||
'viridis', 'plasma', 'inferno', 'magma']), | ||
('Sequential', [ | ||
'Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds', | ||
'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu', | ||
'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn']), | ||
('Sequential (2)', [ | ||
'binary', 'gist_yarg', 'gist_gray', 'gray', 'bone', 'pink', | ||
'spring', 'summer', 'autumn', 'winter', 'cool', 'Wistia', | ||
'hot', 'afmhot', 'gist_heat', 'copper']), | ||
('Diverging', [ | ||
'PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', | ||
'RdYlBu', 'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic']), | ||
('Qualitative', [ | ||
'Pastel1', 'Pastel2', 'Paired', 'Accent', | ||
'Dark2', 'Set1', 'Set2', 'Set3', | ||
'tab10', 'tab20', 'tab20b', 'tab20c']), | ||
('Miscellaneous', [ | ||
'flag', 'prism', 'ocean', 'gist_earth', 'terrain', 'gist_stern', | ||
'gnuplot', 'gnuplot2', 'CMRmap', 'cubehelix', 'brg', 'hsv', | ||
'gist_rainbow', 'rainbow', 'jet', 'nipy_spectral', 'gist_ncar'])] | ||
|
||
|
||
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, nrows): | ||
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, nrows) | ||
|
||
plt.show() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth adding a section (maybe in another PR?) that lists all colorblind-friendly colormaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm all for that/think that's a great idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be added to this example. This is a reference list. This should be (if it isn't already) in the colormap tutorial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why shouldn't a reference list provide accessibility references?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be handled by including a reference here to the tutorial section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so, so long as there's an explicit mention of colorblind maps, something "See the tutorial for a more detailed explanation of colormaps, including information on colorblind friendly"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just delete all the text (it's a reference!) and replace it by "for an in-depth overview of colomaps, including discussion about colorblind-friendliness, see (tutorial)".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no information on colorblind maps in the tutorial, just outside references.
Feel free to merge or close if you feel this is not an improvement to the documentation.