對於下面給出的程式碼,我收到以下錯誤:
包 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}