我正在尝试使用代码绘制 3D 曲线 $x=e^(t)*cos(t),y=e^(t)*sin(t),z=e^(t)$,$t\in[0,1]$
\documentclass[tikz, border=2mm]{amsbook}
\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
\begin{axis}
[view={60}{30},axis lines=center,axis on top,
xlabel=$x$,ylabel=$y$,zlabel=$z$, xtick={2},ytick={2},ztick={2},no marks,axis equal,xmin=-1,xmax=4,ymin=-1,ymax=4,zmin=-1,zmax=4,enlargelimits={upper=0.1}]
\addplot3+[no markers,samples=200, domain=0:1,variable=t]({exp(t)*cos(t)},{exp(t)*sin(t)},{exp(t)});
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
什么都没绘制出来。我该如何修复这个问题?
答案1
首先,我认为您打算将其用作standalone
类。然后变量名应该是一个宏。此外,三角函数接受以度为单位的参数。因此,您需要提到它们以弧度为单位,并附加一个r
。要删除与初始点的最终连接,您可以添加samples y=0
,例如对于-pi:pi
您获得的域
\addplot3+[no markers,samples=51, samples y=0,domain=-pi:pi,variable=\t]
({exp(\t)*cos(\t r)},{exp(\t)*sin(\t r)},{exp(\t)});
完整代码
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={60}{30},
axis lines=center,axis on top,
xlabel=$x$,ylabel=$y$,zlabel=$z$,
xtick={2},ytick={2},ztick={2},
no marks,axis equal,
xmin=-1,xmax=4,ymin=-1,ymax=4,zmin=-1,zmax=4,
enlargelimits={upper=0.1}]
\addplot3+[no markers,samples=51, samples y=0,domain=-pi:pi,variable=\t]
({exp(\t)*cos(\t r)},{exp(\t)*sin(\t r)},{exp(\t)});
\end{axis}
\end{tikzpicture}
\end{document}