# Color Blind Friendly Mesh Colormap

I have a plot with a mesh and it uses a lovely colormap, however, I can't find a way to make tikzpicture only use colorblind friendly colors. I'm not colorblind, but I know at least some of the people who will be reading my technical document are. Any ideas on how to fix it?

## Minimal Working Example

For example, the following code produces a figure with a colormap that may not be acceptable:

\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\begin{axis}[nodes near coords={(\coordindex)},
title=Rectangle from matrix input]
% note that surf implies 'patch type=rectangle'
patch type=rectangle]
{x*y};
\end{axis}
\end{tikzpicture}
\end{document}


This results in:

• A related question asking about how to use colors defined by ColorBrewer in PGFPlots. According to their website, "ColorBrewer is an online tool designed to help people select good color schemes for maps and other graphics." – I Like to Code Feb 28 '14 at 1:03
• Colour blindness exists in a multitude of flavours. Could you maybe specify which one you are referring to? Or do you want it to be useable by people with any type of colourblindness? – Saaru Lindestøkke Feb 28 '14 at 1:12
• As Bart Arondson already stated: There are basically two types of colour blindness: red-green and blue-yellow colour blindness, the first affects about 5% of population, the second is very rare, so may statements concern the first kind: You should not use red and green colours combined in your colour map. I am not colourblind, but sometimes work with colourblind pupils. – user31729 Feb 28 '14 at 5:06
• @BartArondson ChristianH With sufficient contrast of colors it doesn't matter which one an individual has. You can avoid it safely and it doesn't need to be like black and yellow colors all around like a radiation sign to be colorblind friendly unlike many others might think. I have red-green btw. – percusse Feb 28 '14 at 7:02
• @percusse: ILikeToCode linked to question with an answer of Jake. You could give an answer here which of the colour styles are good distinguishable from your point of view. (Sic! But truly no pun intended.) Jake wrote this as PGFPlots library, would be interesting, whether this could be more generalized for TikZ. – Speravir Feb 28 '14 at 19:28

I think the following will work for any type of colorblindness as it uses only one color:

\documentclass[varwidth=true, border=2pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.9}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\pgfplotsset{
colormap={whitered}{
color(0cm)=(white);
color(1cm)=(orange!75!red)
}
}
\begin{tikzpicture}
\begin{axis}[
colormap name=whitered,
title=Rectangle from matrix input,
colorbar,
colorbar style={
at={(-0.3,0)},
anchor=south west,
height=0.6*\pgfkeysvalueof{/pgfplots/parent axis height},
title={$f(x,y)$}
}]