# Greyscale compatible colours for TikZ

I am looking for five different colours/fill styles for the bars in a TikZ chart. The bars are quite narrow. I want them to be distinctive when viewed onscreen or printed in colour, but also distinctive if the same PDF file gets printed in black and white.

Can anyone recommend a good set of colour definitions? Or some other way of filling the bars to make them distinctive in both scenarios? A bonus (non-essential) would be if colour-blind people could also tell them apart easily.

To clarify, I do not want to produce a greyscale PDF file, or generate a separate output for black and white printing, as I have seen in some other answers. Thanks!

• Do you mind getting 6 colors instead? graphicdesign.stackexchange.com/q/80522/27774 – Symbol 1 Mar 2 at 20:31
• @Symbol1 unfortunately that question didn't get a conclusive answer. The most helpful suggestion there was to use ColorBrewer. It only recommends one 5-colour scheme as "photocopy-safe", which didn't work well for me when I tried it. For reference, its RGB codes were ['rgb(215,25,28)','rgb(253,174,97)','rgb(255,255,191)','rgb(171,221,164)','rgb(43,131,186)'] – JRI Mar 24 at 6:52
• Too bad. There is still graphicdesign.stackexchange.com – Symbol 1 Mar 24 at 16:52

I would suggest using a basic color that you can then mix with different amounts of white and black to create five different shades of this color. In the following example, I have used blue as the base color, but the same can also be done using other colors (such as red and green, as shown in the image below).

\documentclass[a4paper, 12pt]{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=6,
xtick={1,2,3,4,5},
ytick={0,5},
ymin=0,
ymax=5,
every axis plot/.append style={
ybar,
bar width=10pt,
bar shift=0pt,
fill
}
]
\end{axis}
\end{tikzpicture}
\end{document}


The same bar charts converted to grayscale are shown next to the coresponding colored chart in the following image:

• Thanks for the suggestion. Unfortunately, it didn't work for me in practice. I found that with the colour and B&W printers available to me, the darker shades were not sufficiently distinct. However, it did help me think of a working solution, which I'll put in a separate answer. – JRI Mar 24 at 7:04
• @JRI: If you wish to stay with the blue color, you might want to use \addplot[draw=black,fill=white]coordinates {(1,5)}; \addplot[draw=black,fill=blue!10!white]coordinates{(2,5)}; \addplot[draw=black,fill=blue!45!white]coordinates{(3,5)}; \addplot[draw=black,fill=blue!70!white]coordinates{(4,5)}; \addplot[draw=black,fill=black]coordinates{(5,5)}; The result im comparison to the colors in your answer is the following: i.stack.imgur.com/bPcpT.png – leandriis Mar 24 at 9:16

@leandriis's solution of mixing colour with a certain proportion of black or white helped me reach a solution, but I found that the colours it produced were not distinct enough when printed, either in colour or greyscale. To make the shades distinct in greyscale, I added solid black and solid white (with a black border). To make them more distinct in colour, I used different hues (red, green, blue). However, my blues always came out darker than expected when converted to greyscale, so I ended up replacing blue with a grey.

Here's what I ended up with, using @leandriis's source code for the demo:

\documentclass[a4paper, 12pt]{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
xmin=0,
xmax=6,
xtick={1,2,3,4,5},
ytick={0,5},
ymin=0,
ymax=5,
every axis plot/.append style={
ybar,
bar width=10pt,
bar shift=0pt,
fill
}
]