Hi Ariel,
You might find the attached function helpful here. Try creating a new
colormap using the example in the docstring (you could also try setting
high=0.8) - basically this will let you turn down the saturation which
will hopefully solve your problem. You may also find the plot option
useful to see what the individual colour channels are doing if you
decide to make a new colormap of your own - you just need to ensure that
the r, g, and b values match at both ends.
Gary
Ariel Rokem wrote:
Hi everyone,
I am interested in using a circular colormap, in order to represent a
phase variable, but I don't like 'hsv' (which is circular). In
particular, I find that it induces perceptual distortion, where values
in the green/yellow part of the colormap all look the same. Are there
any circular colormaps except for 'hsv'? If not - how would you go about
constructing a new circular colormap?
Thanks,
Ariel
--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import matplotlib._cm as _cm
def rescale_cmap(cmap_name, low=0.0, high=1.0, plot=False):
'''
Example 1:
my_hsv = rescale_cmap('hsv', low = 0.3) # equivalent scaling to
cplot_like(blah, l_bias=0.33, int_exponent=0.0)
Example 2:
my_hsv = rescale_cmap(cm.hsv, low = 0.3)
'''
if type(cmap_name) is str:
cmap = eval('_cm._%s_data' % cmap_name)
else:
cmap = eval('_cm._%s_data' % cmap_name.name)
LUTSIZE = plt.rcParams['image.lut']
r = np.array(cmap['red'])
g = np.array(cmap['green'])
b = np.array(cmap['blue'])
range = high - low
r[:,1:] = r[:,1:]*range+low
g[:,1:] = g[:,1:]*range+low
b[:,1:] = b[:,1:]*range+low
_my_data = {'red': tuple(map(tuple,r)),
'green': tuple(map(tuple,g)),
'blue': tuple(map(tuple,b))
}
my_cmap = colors.LinearSegmentedColormap('my_hsv', _my_data, LUTSIZE)
if plot:
plt.figure()
plt.plot(r[:,0], r[:,1], 'r', g[:,0], g[:,1], 'g', b[:,0], b[:,1], 'b',
lw=3)
plt.axis(ymin=-0.2, ymax=1.2)
return my_cmap
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users