# How to use every plot with TikZ

In the paragraph about gnuplot in the pgfmanual, I read this :

The following styles influence the plot: /tikz/every plot (style, initially empty) This style is installed in each plot, that is, as if you always said plot[every plot,...] This is most useful for globally setting a prefix for all plots by saying:

 \tikzset{every plot/.style={prefix=plots/}}


I try this with no succes.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[domain=0:4,every plot/.style={green,ultra thick}]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw plot[id=x]   function{x}    node[right] {$f(x) =x$};
\draw plot[id=sin] function{sin(x)}      node[right] {$f(x) = \sin x$};
\draw plot[id=exp] function{0.05*exp(x)} node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}

\end{document}

-

Since the color options are part of the \draw command, they won't be seen as options passed to the plot command. So the only things that can go into every plot/.style are actual plot options, e.g. the parametric option, the domain option, the samples option, all the mark options, etc.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[domain=0:4,every plot/.style={mark=ball,samples=5}]
\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);
\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};
\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};
\draw plot[id=x]   function{x}    node[right] {$f(x) =x$};
\draw plot[id=sin] function{sin(x)}      node[right] {$f(x) = \sin x$};
\draw plot[id=exp] function{0.05*exp(x)} node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};
\end{tikzpicture}

\end{document}


-