From de5906ff842caafc13183d00ea8512acf7fcfe86 Mon Sep 17 00:00:00 2001 From: "Kristen M. Thyng" Date: Thu, 3 Dec 2015 10:50:36 -0600 Subject: [PATCH] removed Lfunction since it is outdated and also removed that part from the docs. Changed grayscale plot to use colorspacious CAM02-UCS instead of CIELAB --- doc/users/colormaps.rst | 13 -- doc/users/plotting/colormaps/Lfunction.py | 157 ---------------------- doc/users/plotting/colormaps/grayscale.py | 7 +- 3 files changed, 3 insertions(+), 174 deletions(-) delete mode 100644 doc/users/plotting/colormaps/Lfunction.py diff --git a/doc/users/colormaps.rst b/doc/users/colormaps.rst index c94e76670db5..4217bba877e1 100644 --- a/doc/users/colormaps.rst +++ b/doc/users/colormaps.rst @@ -126,19 +126,6 @@ extension on this idea at [mycarta-jet]_. .. plot:: users/plotting/colormaps/lightness.py - -:math:`L^*` function -==================== - -There are multiple approaches to finding the best function for :math:`L^*` -across a colormap. Linear gives reasonable results (*e.g.*, [mycarta-banding]_, -[mycarta-lablinear]_). However, the Weber-Fechner law, and more generally and -recently, Stevens' Law, indicates that a logarithmic or geometric relationship -might be better (see effort on this front at [mycarta-cubelaw]_). - -.. plot:: users/plotting/colormaps/Lfunction.py - - Grayscale conversion ==================== diff --git a/doc/users/plotting/colormaps/Lfunction.py b/doc/users/plotting/colormaps/Lfunction.py deleted file mode 100644 index d9a06759ea28..000000000000 --- a/doc/users/plotting/colormaps/Lfunction.py +++ /dev/null @@ -1,157 +0,0 @@ -''' -Recreate Josef Albers plot illustrating the Weber-Fechner law and illustrate -with the binary matplotlib colormap, too. Trying to show the difference between -adding blackness to a color at different rates. -''' -import numpy as np -import matplotlib.pyplot as plt -import colorconv as color -#from skimage import color -# 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 matplotlib as mpl -from matplotlib import cm - - -mpl.rcParams.update({'font.size': 12}) - - -### Red, original Albers plot - -nrows = 5 - -# Start with red -red = np.array([np.hstack([np.ones((nrows,1)), np.zeros((nrows,2))])]) - -# Get basic red in LAB -lab_add = color.rgb2lab(red) -lab_geometric = lab_add.copy() - -# Alter successive rows with more black -k = 1 -for i in range(red.shape[1]): - # more blackness is closer to 0 than one, and in first column of LAB - lab_add[0,i,0] = lab_add[0,i,0] - 10*i - if i != 0: - lab_geometric[0,i,0] = lab_geometric[0,i,0] - 10*k - k *= 2 - -# Change LAB back to RGB for plotting -rgb_add = red.copy() # only change red values -temp = color.lab2rgb(lab_add) -rgb_add[0,:,0] = temp[0,:,0] -rgb_geometric = red.copy() # only change red values -temp = color.lab2rgb(lab_geometric) -rgb_geometric[0,:,0] = temp[0,:,0] - -fig = plt.figure(figsize=(5,3)) -k = 1 -for i in range(red.shape[1]): - - # LHS: additive - ax1 = fig.add_subplot(nrows,2,i*2+1, facecolor=tuple(rgb_add[0,i,:])) - - # RHS: multiplicative - ax2 = fig.add_subplot(nrows,2,i*2+2, facecolor=tuple(rgb_geometric[0,i,:])) - - # ylabels - if i!=0: - ax1.set_ylabel(str(1*i)) - ax2.set_ylabel(str(k)) - k *= 2 - - # Turn off ticks - ax1.get_xaxis().set_ticks([]) - ax2.get_xaxis().set_ticks([]) - ax1.get_yaxis().set_ticks([]) - ax2.get_yaxis().set_ticks([]) - - # Turn off black edges - ax1.spines['right'].set_visible(False) - ax1.spines['top'].set_visible(False) - ax1.spines['bottom'].set_visible(False) - ax1.spines['left'].set_visible(False) - ax2.spines['right'].set_visible(False) - ax2.spines['top'].set_visible(False) - ax2.spines['bottom'].set_visible(False) - ax2.spines['left'].set_visible(False) - - -# common ylabel -ax1.text(-0.3, 3.8, 'Additional Parts Black', - rotation=90, transform=ax1.transAxes) - - -fig.subplots_adjust(hspace=0.0) -plt.show() - - -### Albers plot with linear scale black and white - -nrows = 5 -ncols = 2 - -x = np.linspace(0.0, 1.0, 100) -cmap = 'binary' - -# Get binary colormap entries for full 100 entries -rgb = cm.get_cmap(cmap)(x)[np.newaxis,:,:3] - -# Sample 100-entry rgb additively and geometrically -rgb_add = np.empty((1,nrows,3)) -rgb_geometric = np.empty((1,nrows,3)) - -k = 1 -di = 8 -I0 = 5 -for i in range(nrows): - # Do more blackness via increasing indices - rgb_add[:,i,:] = rgb[:,i*di+I0,:] - - if i != 0: - rgb_geometric[:,i,:] = rgb[:,I0+di*k,:] - k *= 2 - elif i==0: - rgb_geometric[:,i,:] = rgb[:,I0,:] - -lab_add = color.rgb2lab(rgb_add) -lab_geometric = color.rgb2lab(rgb_geometric) - -fig = plt.figure(figsize=(5,3)) -k = 1 -for i in range(nrows): - - # LHS: additive - ax1 = fig.add_subplot(nrows,ncols,i*2+1, facecolor=tuple(rgb_add[0,i,:])) - - # middle: multiplicative - ax2 = fig.add_subplot(nrows,ncols,i*2+2, facecolor=tuple(rgb_geometric[0,i,:])) - - # ylabels - if i!=0: - ax1.set_ylabel(str(1*i)) - ax2.set_ylabel(str(k)) - k *= 2 - - # Turn off ticks - ax1.get_xaxis().set_ticks([]) - ax2.get_xaxis().set_ticks([]) - ax1.get_yaxis().set_ticks([]) - ax2.get_yaxis().set_ticks([]) - - # Turn off black edges - ax1.spines['right'].set_visible(False) - ax1.spines['top'].set_visible(False) - ax1.spines['bottom'].set_visible(False) - ax1.spines['left'].set_visible(False) - ax2.spines['right'].set_visible(False) - ax2.spines['top'].set_visible(False) - ax2.spines['bottom'].set_visible(False) - ax2.spines['left'].set_visible(False) - -# common ylabel -ax1.text(-0.3, 4.5, 'Steps through map indices', - rotation=90, transform=ax1.transAxes) - -fig.subplots_adjust(hspace=0.0) -plt.show() diff --git a/doc/users/plotting/colormaps/grayscale.py b/doc/users/plotting/colormaps/grayscale.py index d503deeb3469..7d3e9f38aeac 100644 --- a/doc/users/plotting/colormaps/grayscale.py +++ b/doc/users/plotting/colormaps/grayscale.py @@ -3,8 +3,6 @@ Uses lightness L* as a proxy for grayscale value. ''' -import colorconv as color - from colormaps import cmaps #from skimage import color @@ -14,6 +12,7 @@ import matplotlib.pyplot as plt from matplotlib import cm import matplotlib as mpl +from colorspacious import cspace_converter mpl.rcParams.update({'font.size': 14}) @@ -37,8 +36,8 @@ def plot_color_gradients(cmap_category, cmap_list): # Get rgb values for colormap rgb = cm.get_cmap(plt.get_cmap(name))(x)[np.newaxis,:,:3] - # Get colormap in CIE LAB. We want the L here. - lab = color.rgb2lab(rgb) + # Get colormap in CAM02-UCS colorspace. We want the lightness. + lab = cspace_converter("sRGB1", "CAM02-UCS")(rgb) L = lab[0,:,0] L = np.float32(np.vstack((L, L, L)))