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

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*\\%
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={
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):


stack plots=y,stack dir=minus,
cycle list name=color list]
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};
\addplot coordinates {(0,1) (0.5,1) (1,1)};

enter image description here

  • @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 :)
    – cmhughes
    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.

        % 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*\\
            % 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={
                my marks
                [3 of]linestyles
                very thick
            legend entries={0,...,20},
            legend pos=outer north east,
            \addplot {x};
            \addplot {x-1};
            \addplot {x-2};
            \addplot {x-3};
            \addplot {x-4};
            \addplot {x-5};
            \addplot {x-6};
            \addplot {x-7};
            \addplot {x-8};
            \addplot {x-9};
            \addplot {x-10};
            \addplot {x-11};

image showing the result of above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.