\foreach
我怎样才能在a中使用 pi 这个数字pgfplots
?
\documentclass[tikz, dvipsnames]{standalone}
\usepackage{pgfplots}
\usepackage{mathtools}
\pgfplotsset{compat = 1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\foreach \v/\colo in {0/red, {pi/4}/blue, {pi/2}/orange, {3*pi/4}/green,
{5*pi/4}/Purple, {3*pi/2}/Salmon, {7pi/4}/SeaGreen}{
\expandafter\addplot\expandafter+\expandafter[\colo, domain = 0:2*pi]
({(exp(x) + exp(-x)) / 2 * cos(deg(\v))},
{(exp(x) - exp(-x)) / 2 * sin(deg(\v))});
}
\end{axis}
\end{tikzpicture}
\end{document}
我想v
成为pi
但是
ERROR: Package PGF Math Error: Unknown operator `p' or `pi' (in '(exp(x) + exp(-x)\
) / 2 * cos(deg(7pi/4))').
答案1
{7pi/4}
应该有一个 *
{7*pi/4}