Circular colormaps

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

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:

rescale_cmap.py (1.16 KB)

···

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

... and for dessert, is there a circular colormap that would work for the colorblind?

My department is practicing presenting-science-for-the-general-public, and the problems 'heat maps' have for the colorblind keep coming up.

handy: http://konigi.com/tools/submissions/color-deficit-simulators

&C

···

On Nov 8, 2009, at 3:34 AM, Gary Ruben wrote:

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

... and for dessert, is there a circular colormap that would work for
the colorblind?

Almost certainly not, at least not without compromising other desirable features for circular colormaps. You could do a circle roughly perpendicular to the lines of confusion, but this would mean going up and down in lightness, which perceptually overemphasizes the light half.

On the other hand, this may not be a bad thing if 0 degrees and/or 180 degrees are special as might be the case with phase measurements and other complex number-related things.

My department is practicing presenting-science-for-the-general-public,
and the problems 'heat maps' have for the colorblind keep coming up.

As a deuteronopic, I heartily thank you for paying attention to these issues.

I've written an application to visualize colormaps in 3D perceptual space as well as simulating colorblindness. It uses Mayavi and Chaco, so you will need a full Enthought Tool Suite installation:

http://www.enthought.com/~rkern/cgi-bin/hgwebdir.cgi/colormap_explorer/

Of interest for this thread might be the function find_chroma() in hcl_opt.py which will, given a lightness value in HCL space, find the largest chroma value (roughly similar to saturation) such that a circle at the given lightness value will just fit inside of the RGB gamut. A simple maximization on that function will find the lightness that gives the largest chroma and hence the largest dynamic range of such a colormap. However, it should be noted that I have found such colormaps to appear a little washed out and drab. But then, I'm colorblind.

···

On 2009-11-09 11:46 AM, Chloe Lewis wrote:

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco