Tikz: Define line and marker object in preamble
Tikz: Define line and marker object in preamble
I have a lot of different plots for specific configurations (c1,c2,...,c10) where I only compare some of the configurations. Lets say plot 1: (c1,c4,c10) and in the next plot (c2,c3,c5). Also I will have the same configuration in dashed or dotted multiple times in one plot (i.e. for different locations or times) like plot 3:(c1,c1 dashed, c3, c3 dashed).
Now I want to create objects, storing the color, marker and linestyle information and put them in the preambel, so when I want to change a color all the plots and references change. Thank you for your help in advance!
documentclassstandalone
usepackagepgf, tikz, pgfplots
% define the colors, here I am looking for a command, somthing like:
definestylec01blue,mark=o
% ...
% ... and also maybe dashed ones
definestylec10_dashedgreen!55!black,style=dashed
begindocument
begintikzpicture
beginaxis
addplot[style = c01] coordinates (0,1) (0.5,1.5) (1,1); % now use these here somehow
addplot[style = c10_dashed] coordinates (0,2) (0.5,2.5) (1,2);
endaxis
endtikzpicture
enddocument
1 Answer
1
You can define your own keys with pgfplotsset
. For example,
pgfplotsset
documentclassstandalone
usepackagepgf, tikz, pgfplots
pgfplotssetcompat=1.16
pgfplotssetc01/.style=blue,mark=o
pgfplotssetc10_dashed/.style=green!55!black,style=dashed
begindocument
begintikzpicture
beginaxis
addplot[c01] coordinates (0,1) (0.5,1.5) (1,1); % now use these here somehow
addplot[c10_dashed] coordinates (0,2) (0.5,2.5) (1,2);
endaxis
endtikzpicture
enddocument
This use the pgf keys mechanism described in the pgf documentation.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Welcome to TeX - LaTeX!
– Andrew Swann
Aug 19 at 12:43