对于下面给出的代码,我收到以下错误:
包 PGF 数学错误:未知运算符c' or
co'(在'{4cos(deg(x))}'中)。
包 PGF 数学错误:未知运算符p' or
pi'(在'2pi'中)。
包 PGF 数学错误:未知运算符p' or
pi'(在'2pi'中)。
请帮忙
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{graphicx} % Required for inserting images
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\draw[<->] (-4,0) -- (4,0) node[right] {$x$};
\draw[<->] (0,-4) -- (0,4) node[above] {$y$};
\draw[dashed] (0,-4) -- (0,4);
\draw[blue,thick,->] plot [domain=0:2pi,samples=100] ({0},{4cos(deg(x))});
\draw[red,thick,->] plot [domain=0:2pi,samples=100] ({0},{-4cos(deg(x))});
\end{tikzpicture}
\end{center}
\end{document}
答案1
尝试这个:
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{amsmath}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{graphicx} % Required for inserting images
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\begin{document}
\begin{center}
\begin{tikzpicture}[scale=0.8]
\draw[<->] (-4,0) -- (4,0) node[right] {$x$};
\draw[<->] (0,-4) -- (0,4) node[above] {$y$};
\draw[dashed] (0,-4) -- (0,4);
\draw[blue,thick,domain=0:{2*pi},samples=100] plot ({\x},{4*cos(\x r)});
\draw[red,thick,domain=0:{2*pi},samples=100] plot ({\x},{-4*cos(\x r)});
\end{tikzpicture}
\end{center}
\end{document}