Let’s say you add five data series to a bar plot and they would get the colors blue – red – brown – gray – purple. Now suppose you have another plot with only four data series, but you would like them to have the colors blue – red – gray – purple, because they are similar to the series 1, 2, 4 and 5 in the first plot. You also don’t want to change the order. What can you do?
The style (colors, markers, etc) for a dataseries are determined by the cycle list
in pgfplots. This is a series of style definitions that are applied to your data series one after the other. You can of course define one cycle list for each of the plots and assign the colors the way you want:
\pgfplotscreateplotcyclelist{my five bars}{% solid,fill,blue, \\% solid,fill,red, \\% solid,fill,brown, \\% solid,fill,gray, \\% solid,fill,purple, \\% } \pgfplotscreateplotcyclelist{my four bars}{% solid,fill,blue, \\% solid,fill,red, \\% solid,fill,gray, \\% solid,fill,purple, \\% } \begin{tikzpicture} \begin{axis}[cycle list name=my five bars,...] ... add the five data series ... \end{axis} \end{tikzpicture} \begin{tikzpicture} \begin{axis}[cycle list name=my four bars,...] ... add the four data series ... \end{axis} \end{tikzpicture}
But you always need to remember to change both versions. Fortunately there is an easier way! You can shift the index of the cycle list:
\begin{axis}[cycle list name=my five bars,...] ... add first two data series ... \pgfplotsset{cycle list shift=1} % Skips one style ... add the other two data series ... \end{axis} \end{tikzpicture}
Done!