# How to differentiate many lines in a chart? [duplicate]

I create a chart with many (actually 10) lines in different colors (see example). I want to make it as easy as possible to differentiate the different lines.

Some possibilities I have in mind:

• Take most different colors
• Avoid light colors (e.g. yellow - on prints the line are hard to see)
• Use patterns (dashed, dotted, different dash pattern) TikZ: Get values for predefined dash patterns
• Use different thickness (I don't believe this is a good idea)

Are there best practices, rules or guides for this task?

My example code:

\documentclass[border=5mm] {standalone}
\usepackage{pgfplots, pgfplotstable}
\begin{document}
description&A&B&C&D&E&F&G&H&I&K
2009&46&0&33&3&0&74&3&7&2&7
2010&35&0&22&1&0&90&2&5&3&3
2011&38&0&33&3&1&77&1&9&2&8
2012&25&0&15&0&4&55&4&5&0&1
2013&18&0&8&0&0&46&5&4&0&3
2014&37&0&54&1&3&54&5&12&10&2
2015&29&0&63&8&1&77&0&8&7&5
}\datatableentry
\begin{tikzpicture}
\begin{axis}[
title={My Chart},
enlarge y limits ={value=0.2,upper},
xtick=data,
xticklabels ={2009,2010,2011,2012,2013,2014,2015},
x tick label style={rotate=-45,anchor=west,font=\tiny},
legend style={font=\tiny,legend pos=north west,legend cell align=left},
]
\addplot [color=blue] table [y=A, x expr=\coordindex] {\datatableentry};
\addplot [color=cyan] table [y=B, x expr=\coordindex] {\datatableentry};
\addplot [color=gray] table [y=C, x expr=\coordindex] {\datatableentry};
\addplot [color=yellow] table [y=D, x expr=\coordindex] {\datatableentry};
\addplot [color=green] table [y=E, x expr=\coordindex] {\datatableentry};
\addplot [color=lime] table [y=F, x expr=\coordindex] {\datatableentry};
\addplot [color=black,loosely dashed] table [y=G, x expr=\coordindex] {\datatableentry};
\addplot [color=red,densely dashed] table [y=H, x expr=\coordindex] {\datatableentry};
\addplot [color=blue,dotted] table [y=I, x expr=\coordindex] {\datatableentry};
\addplot [color=cyan,dashed] table [y=K, x expr=\coordindex] {\datatableentry};
\end{axis}
\end{tikzpicture}
\end{document}


Disclaimer: I'm not sure if this question belongs to http://graphicdesign.stackexchange.com. The main problem is a design question, but the solution is needed in Tikz.

• For accessibility and universal design reasons, it's a good idea to distinguish using line style as well as colour; I'd also highly recommend using pgfplots cyclelist tools to help with this – cmhughes Mar 7 '14 at 17:00
• My two-cents question: Are you sure you even want a chart with that many lines? And that much amplitude between the near-flat ones and the sky-high ones. 2-3 lines are hard enough to read, and difficult enough to distinguish other than based on colour (most people print in black and white). I, for one, couldn't read your chart if my life depended on it. Isn't there another way in which you could convey your data? – ienissei Mar 10 '14 at 11:55
• @ienissei I had similar thoughts, but no real solution up to now. That's why I tried to make bigger differences. At least it is not so important to separate the near-flat one values (they are near flat, so they are low values and not so important). Peaks are from interest. I think the marks will be a good solution for this. – knut Mar 10 '14 at 12:01
• @knut Then maybe you need to select the relevant information that goes into the chart. To me, there is a whole bunch of things that I can't read because they overlap so much – and since charts are the best way of hiding the important stuff, I wouldn't rely on the peaks to tell me what is important. Just a reader's experience. I know how difficult it is to make the right graphic representation of the data you have… I am glad the answer that was posted works for you. – ienissei Mar 10 '14 at 12:06

I can not say, what the best way is to do it, from a design point of view. -but I can show what I did in a similar case. -using colors and marks.

\documentclass{standalone}
\usepackage{siunitx}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{semilogxaxis}
[
width=\figwidth,
height=0.75*\figwidth,
scale only axis,
font=\tiny,
xmin=1, xmax=5000, xlabel={Energy [\si{\kilo\electronvolt}]},
ymin=0, ymax=2.5, ylabel={Cross Section [\si{\angstrom\squared}]},
log base 10 number format code/.code={ \pgfmathparse{10^(#1)}\num[round-mode=places, round-precision=0]{\pgfmathresult} },
yticklabel={ \pgfmathparse{\tick*1}\num[round-mode=places,round-precision=1]{\pgfmathresult} },
minor x tick num=9, minor y tick num=1,
every tick/.append style={color=black},
tick pos=left,
legend style={draw=none, fill=none, inner ysep=0pt, outer sep=2pt, nodes={inner sep=1pt}, at={(1,1)}, anchor=north east},
legend cell align=left,
cycle multi list={{mark=+,mark=o}\nextlist{brown,magenta,teal,blue,lime,green,orange,cyan,gray}},
mark size=0.8
]

...
\node[anchor=west] at (axis cs: 1.2, 1.48) {F.--T. effective};
\node[anchor=west] at (axis cs: 1.2, 0.44) {Fermi--Teller limit};

\end{semilogxaxis}
\end{tikzpicture}
\end{document}


It is not easy to distinguish the plots on this picture, but it is much easier in print. -also the distinguishing is only important, where the plots diverge.

I only used solid lines an two different markers, which I think makes the nicest result.