Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

1 Answer 1

up vote 6 down vote accepted

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}

output of code

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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