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.
Really excellent. If you want to make a black background.
Really great work. And matlab should make colorblind colormaps available for all there plots.
Awesome! Used this for a plot for my colorblind boss.
sorry, that's line 44 -- where arg parsing is done
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);
a simple change in line 4 can resolve this.
@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.
I really like this function.
Once I worked out the colormaps for my submission (Perceptually improved colormaps ) I had a bunch of scripts like the one below:
% Edge colors
% k=[0 0 0];
% b=[0 0 1];
% c=[0 1 1];
% w=[1 1 1];
% y=[1 1 0];
% r=[1 0 0];
% edge=interp1(linspace(1, n, 7),[k;b;c;w;y;r;k],[1:1:n]);
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)
Thank you !
Nice - you can also see values for all their cmaps at:
I remember that EOS article and I'm glad someone has written some code to implement it. Got the function running no problem.
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.
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.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.