# pgfplots line colors

Is it possible to make pgfplots use a predefined color map while plotting multiple lines, I currently have 9 samples that I want to plot, but don't want to type different colors for each one. Right now they are all showing up as black. Let me know if this is possible, thanks!

You can use cycle list name=<list>. there are few pre-defined lists --

1. color (from top to bottom)
2. exotic
3. black white
4. mark list
5. mark list*
6. linestyles
7. linestyles*
8. auto

If you want you can create your own list like

\pgfplotscreateplotcyclelist{mycolorlist}{%
blue,every mark/.append style={fill=blue!80!black},mark=*\\%
red,every mark/.append style={fill=red!80!black},mark=square*\\%
brown!60!black,every mark/.append style={fill=brown!80!black},mark=otimes*\\%
black,mark=star\\%
blue,every mark/.append style={fill=blue!80!black},mark=diamond*\\%
red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=*\\%
brown!60!black,densely dashed,every mark/.append style={
solid,fill=brown!80!black},mark=square*\\%
black,densely dashed,every mark/.append style={solid,fill=gray},mark=otimes*\\%
blue,densely dashed,mark=star,every mark/.append style=solid\\%
red,densely dashed,every mark/.append style={solid,fill=red!80!black},mark=diamond*\\%
}


and use it as cycle list name=mylist.

Code (taken from pgfplots manual):

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[
stack plots=y,stack dir=minus,
cycle list name=color list]
\end{axis}
\end{tikzpicture}
\end{document}


• @cmhughes For the code given above, yes, it is the expected output (same in manual also) :)
– user11232
Apr 7 '14 at 23:48
• oh, I see that you didn't actually use the cycle list that you created :) Apr 7 '14 at 23:50
• @cmhughes No, It is just color list which is pre-defined. :)
– user11232
Apr 7 '14 at 23:57
• auto seems to be the default. As usual the problem with automatic list is that eventually they hit yellow. :)
– alfC
Jan 11 '18 at 0:09
• Note that \addplot[<additional options>] ignores the color list. If you need to add option(s), you can use \addplot+[<options]. Also note that, unlike \draw, \addplot[\color] is not compatible with \foreach \color in {blue, red, green} since it gathers only the coordinates but no style options in the "survey phase" (see mrunix.de/forums/…)
– F1iX
Jul 29 '20 at 13:02

With the release of PGFPlots v1.13 it is much easier to define cycle lists, because now there exist much more possibilities. For example cycle lists can be combined from other cycle lists. With that you can define your "default" color cycle list and then combine it with others to fit certain requirements.

Here you can see an example using the cycle multiindex* list key. For more have a look at section 4.7.7 on page 194 of the PGFPlots manual.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{
pgfplots.colorbrewer,
}
\pgfplotsset{
% define a cycle list' for marker
cycle list/.define={my marks}{
every mark/.append style={solid,fill=\pgfkeysvalueof{/pgfplots/mark list fill}},mark=*\\
every mark/.append style={solid,fill=\pgfkeysvalueof{/pgfplots/mark list fill}},mark=square*\\
every mark/.append style={solid,fill=\pgfkeysvalueof{/pgfplots/mark list fill}},mark=triangle*\\
every mark/.append style={solid,fill=\pgfkeysvalueof{/pgfplots/mark list fill}},mark=diamond*\\
},
}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
% load a color cycle list' from the colorbrewer' library
cycle list/RdGy-6,
% define fill color for the marker
mark list fill={.!75!white},
% create new cycle list from existing cycle list's and an
cycle multiindex* list={
RdGy-6
\nextlist
my marks
\nextlist
[3 of]linestyles
\nextlist
very thick
\nextlist
},
samples=3,
legend entries={0,...,20},
legend pos=outer north east,
]