# A good divergent color palette for Matlab

#### INTRODUCTION

Before starting my series on perceptual color palettes I thought it was worth mentioning an excellent function I found some time ago on the Matlab File Exchange. The function is called Light and Bartlein Color Maps. It was a Matlab Pick of the week, and it can be used to create four color palettes discussed in the EOS paper by Light and Bartlein. Each of these palettes is suited for a specific task, and the authors claim they are non confusing for viewers with color vision deficiencies.

In the remainder of this post I will showcase one of the palettes, called orange-white-purple, as it is good divergent scheme [1]. With the code below I am going to load the World Topography Matlab demo data, create  the palette and use it to display the data.

```%% load World Topography Matlab demo

%% create Light Bartlein orange-white-purple diverging scheme
LB=flipud(lbmap(256,'BrownBlue')); % flip it so blue is for negative(ocean)
% and green for positive (land)

%% plot map
fig2 = figure;
imagesc(flipud(topo));
axis equal
axis tight
axis off
set(fig2,'Position',[720 400 980 580]);
title(' Non-symmetric divergent orange-white-purple palette','Color',...
'k','FontSize',12,'FontWeight','demi');
colormap(LB);
colorbar;```

And here is the result below. I like this color scheme better than many othera for divergent data. One only issue in the figure, although not inherently due to the palette itself [2], is that the centre of the palette is not at the zero. This is a problem since the zero is such an important element in ratio data, in this case representing sea level.

#### MAKING THE PALETTE SYMMETRIC AROUND THE ZERO

The problem fortunately can be easily fixed by clipping the data limit to a symmetric range. In Matlab this has to be done programmatically, and rather than going about it with trial and error I like to do it automatically with the code below:

# A rainbow for everyone

#### Traffic lights for everyone

Stephen Westland of Colour chat recently posted about a clever new LED traffic light developed in Japan. Here’s my tweet with the link to Westland’s original blog post:

I really like the idea of making a traffic light that works for everyone: for people with full color vision and people with color vision deficiencies. In fact, I think we should do the same with our color palettes. Why do I say that?

#### A rainbow for everyone

Take a look at  Figure 1 below. This is a map of the Bouguer Gravity (terrain corrected Bouguer Gravity to be precise)  in Southern Tuscany, colored using a rainbow palette. I intentianally left out the colorbar. For a moment ignore the sharp gradient changes at the yellow and cyan color (that is one of the topics of my upcoming series “The rainbow is dead…long live the rainbow!”). Can you tell which color is representing high values an which low? If you have used a mnemonic like ROY B GIV and can tell that highs are towards the Southwest and lows towards the Northeast, then you are right and you also have full color vision, just like me. Great, because this post is exacly for us, the “normals”.

Figure 1

Take now a look at Figure 2: