-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
New Colormaps to docs #5284
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
New Colormaps to docs #5284
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8aec046
Add new colormaps to colormaps_reference
jenshnielsen 4bc613f
Add new colormaps to lightness
jenshnielsen cda8be5
Lfunction tweak size and pep8
jenshnielsen b6565ea
Add colormaps to grayscale
jenshnielsen 38b8911
colormaps format text
jenshnielsen db5f443
"perceptually uniform"
mdboom db403c3
Formatting only
mdboom e3bdf44
Add new category for perceptually uniform colormaps
mdboom ba19f2b
Can't reuse mapping here.
mdboom e01552c
Address @QuLogic's feedback
mdboom 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
Add new colormaps to lightness
Also partly pep8 and make the figure a bit smaller
- Loading branch information
commit 4bc613f447653ec816f8154fbdffad27d610f46d
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 |
---|---|---|
|
@@ -6,15 +6,17 @@ | |
|
||
import colorconv as color | ||
#from skimage import color | ||
# we are using a local copy of colorconv from scikit-image to reduce dependencies. | ||
# we are using a local copy of colorconv from scikit-image to | ||
# reduce dependencies. | ||
# You should probably use the one from scikit-image in most cases. | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
from matplotlib import cm | ||
import matplotlib as mpl | ||
|
||
mpl.rcParams.update({'font.size': 14}) | ||
mpl.rcParams['font.sans-serif'] = 'Arev Sans, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Helvetica, Avant Garde, sans-serif' | ||
mpl.rcParams.update({'font.size': 12}) | ||
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans,' | ||
'Lucida Grande, Verdana, Geneva, Lucid, Helvetica, Avant Garde, sans-serif') | ||
mpl.rcParams['mathtext.fontset'] = 'custom' | ||
mpl.rcParams['mathtext.cal'] = 'cursive' | ||
mpl.rcParams['mathtext.rm'] = 'sans' | ||
|
@@ -24,15 +26,17 @@ | |
mpl.rcParams['mathtext.sf'] = 'sans' | ||
mpl.rcParams['mathtext.fallback_to_cm'] = 'True' | ||
|
||
# Have colormaps separated into categories: http://matplotlib.org/examples/color/colormaps_reference.html | ||
# Have colormaps separated into categories: | ||
# http://matplotlib.org/examples/color/colormaps_reference.html | ||
|
||
cmaps = [('Sequential', ['Blues', 'BuGn', 'BuPu', | ||
'GnBu', 'Greens', 'Greys', 'Oranges', 'OrRd', | ||
'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu', | ||
'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd']), | ||
('Sequential (2)', ['afmhot', 'autumn', 'bone', 'cool', 'copper', | ||
'gist_heat', 'gray', 'hot', 'pink', | ||
'spring', 'summer', 'winter']), | ||
'gist_heat', 'gray', 'hot', 'inferno', 'magma', | ||
'pink', 'plasma', 'spring', 'summer', 'viridis', | ||
'winter']), | ||
('Diverging', ['BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', | ||
'RdBu', 'RdGy', 'RdYlBu', 'RdYlGn', 'Spectral', | ||
'seismic']), | ||
|
@@ -60,14 +64,13 @@ | |
dsub = 7 | ||
nsubplots = int(np.ceil(len(cmap_list)/float(dsub))) | ||
|
||
fig = plt.figure(figsize=(11.5,4*nsubplots)) | ||
fig = plt.figure(figsize=(7,2.6*nsubplots)) | ||
|
||
for i, subplot in enumerate(range(nsubplots)): | ||
|
||
locs = [] # locations for text labels | ||
|
||
ax = fig.add_subplot(nsubplots, 1, i+1) | ||
# pdb.set_trace() | ||
|
||
for j, cmap in enumerate(cmap_list[i*dsub:(i+1)*dsub]): | ||
|
||
|
@@ -79,10 +82,12 @@ | |
|
||
# Plot colormap L values | ||
# Do separately for each category so each plot can be pretty | ||
# to make scatter markers change color along plot: http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable | ||
# to make scatter markers change color along plot: | ||
# http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's (apparently) a little known secret that stackoverflow links can be shortened to http://stackoverflow.com/q/8202605 |
||
if cmap_category=='Sequential': | ||
dc = 0.6 # spacing between colormaps | ||
ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap + '_r', s=300, linewidths=0.) | ||
ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap + '_r', | ||
s=300, linewidths=0.) | ||
if i==2: | ||
ax.axis([-0.1,4.1,0,100]) | ||
else: | ||
|
@@ -91,27 +96,34 @@ | |
|
||
elif cmap_category=='Sequential (2)': | ||
dc = 1.15 | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, s=300, linewidths=0.) | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, | ||
s=300, linewidths=0.) | ||
ax.axis([-0.1,7.0,0,100]) | ||
locs.append(x[-1]+j*dc) # store locations for colormap labels | ||
# store locations for colormap labels | ||
locs.append(x[-1]+j*dc) | ||
|
||
elif cmap_category=='Diverging': | ||
dc = 1.2 | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, s=300, linewidths=0.) | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, | ||
s=300, linewidths=0.) | ||
ax.axis([-0.1,7.1,0,100]) | ||
locs.append(x[int(x.size/2.)]+j*dc) # store locations for colormap labels | ||
|
||
# store locations for colormap labels | ||
locs.append(x[int(x.size/2.)]+j*dc) | ||
elif cmap_category=='Qualitative': | ||
dc = 1.3 | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, s=300, linewidths=0.) | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, | ||
s=300, linewidths=0.) | ||
ax.axis([-0.1,6.3,0,100]) | ||
locs.append(x[int(x.size/2.)]+j*dc) # store locations for colormap labels | ||
# store locations for colormap labels | ||
locs.append(x[int(x.size/2.)]+j*dc) | ||
|
||
elif cmap_category=='Miscellaneous': | ||
dc = 1.25 | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, s=300, linewidths=0.) | ||
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap, | ||
s=300, linewidths=0.) | ||
ax.axis([-0.1,6.1,0,100]) | ||
locs.append(x[int(x.size/2.)]+j*dc) # store locations for colormap labels | ||
# store locations for colormap labels | ||
locs.append(x[int(x.size/2.)]+j*dc) | ||
|
||
# Set up labels for colormaps | ||
ax.xaxis.set_ticks_position('top') | ||
|
@@ -123,8 +135,9 @@ | |
for label in labels: | ||
label.set_rotation(60) | ||
|
||
ax.set_xlabel(cmap_category + ' colormaps', fontsize=22) | ||
fig.text(-0.005, 0.55, 'Lightness $L^*$', fontsize=18, transform=fig.transFigure, rotation=90) | ||
ax.set_xlabel(cmap_category + ' colormaps', fontsize=14) | ||
fig.text(0.0, 0.55, 'Lightness $L^*$', fontsize=12, | ||
transform=fig.transFigure, rotation=90) | ||
|
||
fig.tight_layout(h_pad=0.05) | ||
fig.tight_layout(h_pad=0.05, pad=1.5) | ||
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.
Indent again.