Apply same options to multiple `addplot` in pgfplots
Just for future readers: at the time of writing this answer tikzstyle
is deprecated. From the documentation
Starting with pgfplots 1.1,
\tikzstyle
should no longer be used to setpgfplots
options. Although\tikzstyle
is still supported for some olderpgfplots
options, you should replace any occurrence of\tikzstyle
with\pgfplotsset{<style name>/.style={<key-value-list>}}
or the associated/.append style
variant
With this in mind
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\pgfplotsset{style a/.style={color = red, mark = none, dashed}}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-10,
xmax=10,
xlabel={$x$},
ylabel={$y$},
ymin=-10,
ymax=10]
\addplot[style a] {x^2};
\addplot[style a] {x^3 -4};
\end{axis}
\end{tikzpicture}
\end{document}
You can define a style (or more):
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{tikz}
\tikzstyle{style_a}=[color = red, mark = none, dashed]
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmin=-10,
xmax=10,
xlabel={$x$},
ylabel={$y$},
ymin=-10,
ymax=10]
\addplot[style_a] {x^2};
\addplot[style_a] {x^3 -4};
\end{axis}
\end{tikzpicture}
\end{document}