This submission was inspired by comments from Ned Gulley in a recent Blog by Doug Hull. Ned cited an EOS article by A. Light and P.J. Bartlein who proposed some color maps designed for colorblind viewers. This function implements four of the proposed color maps using look-up tables (aka interpolation). A link to the article is included in the M-file.
Great function, though it bugs if you call lbmap with only a text argument, e.g.
Error using /
Matrix dimensions must agree.
Error in linspace (line 31)
y = d1 + (0:n1).*(d2 - d1)/n1;
Error in lbmap (line 62)
idx2 = linspace(0,1,n);
@John D'Errico - John, I just posted on my blog a short review for one of the palettes.
It includes a test for all three types of color dficient vision.
What is interesting is that we've come up with the same solution for a similar task.
But then I started looking at how to wrap these scripts up into a function, and I had little clue where to start, being a complete neophyte.
Going through your function and reading the comments by John above was what I needed, it helped understad a bit more about the way of thinking in creating a function, and forced me also to go read the colormap code. Also MakeColorMap by Doug Hull helped.
In the end, I liked the architecture and style of your function so much so that I used it as a wrapper for my perceptually balanced colormaps. Like Doug Hull says, don't reinvent the wheel (or the thermometer)
Nice - you can also see values for all their cmaps at:
24 Jan 2008
15 Jan 2008
I remember that EOS article and I'm glad someone has written some code to implement it. Got the function running no problem.
20 Nov 2007
After a second look, I realized that the author does describe the meaning of N in the help. And, well, if the author fixes the issue to give it a consistent interface with the colormap function, then I'd certainly rate this a 5 with no hesitation. So I'll up my rating to a 5 now, and hope that he fixes it. This is a nice idea for a function, and it is well done.
16 Nov 2007
I very much like the idea of a colormap designed for color blind users. Are these maps viable for all the major color blind types? I.e., both for red-green and yellow-blue blindnesses? While I believe I know the answer, and I'm sure this is discussed in the references, a note to this effect would be useful to find in the help.
One point - Matlab uses a standard I/O paradigm. When you have a function that normally returns an argument, if no arguments are provided, it just dumps that variable to the variable ans. This is standard. However lbmap fails here. When you call lbmap with no outputs, it returns an error. So if all that you wish is to look at the resulting colormap without storing it in an array, lbmap fails. This is silly, and as I said, completely against the standard paradigm. For example:
??? Error using ==> lbmap at 36
Not enough output arguments.
An alternative is to use the approach used by colormap itself. If no output is supplied, then it does not return an output at all, but merely applies the specified map to the current figure.
The code itself is quite good, simply using interp1 to expand a given map to the desired granularity.
The help is good. It includes a pair of examples. One of the variables is not defined though. While I can guess that a variable called n is the number of points in the resulting color map, an explicit comment to that effect would be helpful. Does it really cost that much more for one or two more lines?
I also like that references were listed in the code.
I found error checks, an H1 line, and nice readable code. Well done in many respects.