Code covered by the BSD License

### Highlights fromLight Bartlein Color Maps

4.8

4.8 | 6 ratings Rate this file 34 Downloads (last 30 days) File Size: 2.2 KB File ID: #17555

# Light Bartlein Color Maps

15 Nov 2007 (Updated 12 Jan 2010)

Generates one of four colormaps using schemes proposed in technical literature

### Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

File Information
Description

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.

Acknowledgements

This file inspired Perceptually Improved Colormaps.

MATLAB release MATLAB 5.2 (R10)
Tags for This File
Everyone's Tags
Tags I've Applied
09 Feb 2013

sorry, that's line 44 -- where arg parsing is done

09 Feb 2013

Great function, though it bugs if you call lbmap with only a text argument, e.g.
lbmap('Blue')
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.

16 Mar 2012

@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.
http://mycarta.wordpress.com/2012/03/15/a-good-divergent-color-palette-for-matlab/

15 Oct 2010

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:

%n=256;
% 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)
http://blogs.mathworks.com/videos/2008/12/18/matlab-example-dont-reinvent-the-wheel/

Thank you !

16 Dec 2008

Nice - you can also see values for all their cmaps at:
http://geography.uoregon.edu/datagraphics/color_scales.htm

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:

>> lbmap(10,'redblue')
??? 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.