这是我的代码。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\vspace{1cm}
\begin{tikzpicture}
\begin{axis}[
view={120}{20},
axis lines=center,
ticks=none,
xmin=-3,xmax=3,ymin=-3,ymax=3, zmin=-1, zmax=4,
xlabel={$x$},xlabel style={at={(ticklabel* cs:1.05)},anchor=south east},
ylabel={$y$},ylabel style={at={(ticklabel* cs:1.05)},anchor=west},
zlabel={$z$},zlabel style={at={(ticklabel* cs:1.05)},anchor=south},
]
\addplot3 [blue, thick, samples=100, samples y=0, domain=0:2] ({x*cos(pi/3)},{x*sin(pi/3)},{x^2});
\end{axis}
\end{tikzpicture}
\end{document}
这看起来不正确,因为曲线应该旋转 pi/3 并更靠近 yz 平面。我做错了什么?
谢谢
答案1
您可能希望添加trig format plots=rad
,以便三角函数能够按照您的意图进行解释。如果不这样做,则只能旋转pi/3 degree~1 degree
。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\vspace{1cm}
\begin{tikzpicture}
\begin{axis}[trig format plots=rad,
view={120}{20},
axis lines=center,
ticks=none,
xmin=-3,xmax=3,ymin=-3,ymax=3, zmin=-1, zmax=4,
xlabel={$x$},xlabel style={at={(ticklabel* cs:1.05)},anchor=south east},
ylabel={$y$},ylabel style={at={(ticklabel* cs:1.05)},anchor=west},
zlabel={$z$},zlabel style={at={(ticklabel* cs:1.05)},anchor=south},
]
\addplot3 [blue, thick, samples=100, samples y=0, domain=0:2] ({x*cos(pi/3)},{x*sin(pi/3)},{x^2});
\end{axis}
\end{tikzpicture}
\end{document}