19

I noticed that when using pgfplots to make plots without specifying style, it automatically assigns the same color and line style to the first input and fifth input, which means the two curves would have the same style...

Any way to avoid that?

Werner
  • 603,163

1 Answers1

27

While the first and fifth plot have the same line colour, the marks are different. However, this might not be enough distinction for your application, e.g. if you don't use markers.

In that case, you can choose from one of the other cycle list names, which are described in section 4.7.7 starting on p. 213 of the current pgfplots documentation (v1.16).

For example, if you set the option cycle list name=exotic for the axis, the first five plots would look like this:

pgpflots with "exotic" cycle list


You can also define your own cycle lists, using

\pgfplotscreateplotcyclelist{<name>}{
{<first style>},
{<second style>},
...
}

Here's an example of a plot style based on the color scheme "Blues" from the Colorbrewer website. For the fifth plot, the color is overridden using the optional argument to \addplot:

plot with custom cycle list

\documentclass{article}
\usepackage{pgfplots}

\definecolor{blues1}{RGB}{198, 219, 239}
\definecolor{blues2}{RGB}{158, 202, 225}
\definecolor{blues3}{RGB}{107, 174, 214}
\definecolor{blues4}{RGB}{49, 130, 189}
\definecolor{blues5}{RGB}{8, 81, 156}

\pgfplotscreateplotcyclelist{colorbrewer-blues}{
{blues1},
{blues2},
{blues3},
{blues4},
{blues5},
}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    cycle list name=colorbrewer-blues,
    no markers,
    every axis plot/.append style=thick]
\addplot {rnd*.5-.25};
\addplot {rnd*.5-0.5};
\addplot {rnd*.5-0.75};
\addplot{rnd*.5-1};
\addplot+[orange,very thick]{rnd*.5+x*0.05-0.75};
\end{axis}
\end{tikzpicture}
\end{document}
Stefan Pinnow
  • 29,535
Jake
  • 232,450