Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fba45fb

Browse files
committed
Merge pull request #5591 from kthyng/update-colormap-user-page
DOC: fixed ordering of lightness plots
2 parents 40b7837 + 95cc35f commit fba45fb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ install:
7878

7979
- |
8080
if [[ $BUILD_DOCS == true ]]; then
81-
pip install $PRE numpydoc ipython
81+
pip install $PRE numpydoc ipython colorspacious
8282
pip install -q $PRE linkchecker
8383
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
8484
wget http://mirrors.kernel.org/ubuntu/pool/universe/f/fonts-humor-sans/fonts-humor-sans_1.0-1_all.deb

doc/users/plotting/colormaps/lightness.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import matplotlib.pyplot as plt
1515
from matplotlib import cm
1616
import matplotlib as mpl
17+
from colorspacious import cspace_converter
1718

1819
mpl.rcParams.update({'font.size': 12})
1920

@@ -46,16 +47,16 @@
4647
# Get rgb values for colormap
4748
rgb = cm.get_cmap(cmap)(x)[np.newaxis,:,:3]
4849

49-
# Get colormap in CIE LAB. We want the L here.
50-
lab = color.rgb2lab(rgb)
50+
# Get colormap in CAM02-UCS colorspace. We want the lightness.
51+
lab = cspace_converter("sRGB1", "CAM02-UCS")(rgb)
5152

5253
# Plot colormap L values
5354
# Do separately for each category so each plot can be pretty
5455
# to make scatter markers change color along plot:
5556
# http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable
5657
if cmap_category=='Perceptually Uniform Sequential':
5758
dc = 1.15 # spacing between colormaps
58-
ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap,
59+
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap,
5960
s=300, linewidths=0.)
6061
if i==2:
6162
ax.axis([-0.1,4.1,0,100])
@@ -65,7 +66,9 @@
6566

6667
elif cmap_category=='Sequential':
6768
dc = 0.6 # spacing between colormaps
68-
ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap + '_r',
69+
# These colormaps all start at high lightness but we want them
70+
# reversed to look nice in the plot, so reverse the order.
71+
ax.scatter(x+j*dc, lab[0,::-1,0], c=x[::-1], cmap=cmap,
6972
s=300, linewidths=0.)
7073
if i==2:
7174
ax.axis([-0.1,4.1,0,100])

0 commit comments

Comments
 (0)