0

I am getting an undefined control sequence when using \col in a \foreach loop.

! Undefined control sequence.
\pgfkeyscurrentkey ->\col

\documentclass[tikz, dvipsnames]{standalone}
\usepackage{mathtools}
\usepackage{pgfplots}
\pgfplotsset{compat = 1.8}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[
    samples = 500,
    no marks,
    xlabel = $\scriptstyle x$,
    ylabel = $\scriptstyle y$
    ]
    \foreach \u/\col in {1/red, 2/blue, 3/OliveGreen}{
      \addplot+[\col, domain = -4:4, variable = \v]
      ({(exp(\u) + exp(-\u)) / 2 * cos(deg(v))},
      {(exp(\u) - exp(-\u)) / 2 * sin(deg(v))});
    }
  \end{axis}
\end{tikzpicture}
\end{document}

And also, how can I use \addlegendentry for the plot with a loop?

dustin
  • 18,617
  • 23
  • 99
  • 204

0 Answers0