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

Skip to content

Commit e74ae79

Browse files
committed
Merge remote-tracking branch 'upstream/v1.5.0-doc' into v1.5.x
2 parents 3028846 + c234879 commit e74ae79

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
@@ -88,7 +88,7 @@ install:
8888
# Neihter is installed as a dependency of IPython since they are not used by the IPython console.
8989
- |
9090
if [[ $BUILD_DOCS == true ]]; then
91-
pip install $PRE numpydoc ipython jsonschema mistune
91+
pip install $PRE numpydoc ipython jsonschema mistune colorspacious
9292
pip install -q $PRE linkchecker
9393
wget https://github.com/google/fonts/blob/master/ofl/felipa/Felipa-Regular.ttf?raw=true -O Felipa-Regular.ttf
9494
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
mpl.rcParams['font.sans-serif'] = ('Arev Sans, Bitstream Vera Sans, '
@@ -57,16 +58,16 @@
5758
# Get rgb values for colormap
5859
rgb = cm.get_cmap(cmap)(x)[np.newaxis,:,:3]
5960

60-
# Get colormap in CIE LAB. We want the L here.
61-
lab = color.rgb2lab(rgb)
61+
# Get colormap in CAM02-UCS colorspace. We want the lightness.
62+
lab = cspace_converter("sRGB1", "CAM02-UCS")(rgb)
6263

6364
# Plot colormap L values
6465
# Do separately for each category so each plot can be pretty
6566
# to make scatter markers change color along plot:
6667
# http://stackoverflow.com/questions/8202605/matplotlib-scatterplot-colour-as-a-function-of-a-third-variable
6768
if cmap_category=='Perceptually Uniform Sequential':
6869
dc = 1.15 # spacing between colormaps
69-
ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap,
70+
ax.scatter(x+j*dc, lab[0,:,0], c=x, cmap=cmap,
7071
s=300, linewidths=0.)
7172
if i==2:
7273
ax.axis([-0.1,4.1,0,100])
@@ -76,7 +77,9 @@
7677

7778
elif cmap_category=='Sequential':
7879
dc = 0.6 # spacing between colormaps
79-
ax.scatter(x+j*dc, lab[0,::-1,0], c=x, cmap=cmap + '_r',
80+
# These colormaps all start at high lightness but we want them
81+
# reversed to look nice in the plot, so reverse the order.
82+
ax.scatter(x+j*dc, lab[0,::-1,0], c=x[::-1], cmap=cmap,
8083
s=300, linewidths=0.)
8184
if i==2:
8285
ax.axis([-0.1,4.1,0,100])

0 commit comments

Comments
 (0)