我正在尝试绘制一个螺旋,使其方向如草图所示。螺旋从屏幕中伸出。
下面的脚本生成最后显示的图表,但无论我做什么,似乎都无法获得如上所示的方向。查看 pgfplot 手册,我认为我只能绕 z 轴旋转并垂直上下旋转,对吗?有什么建议吗?
\begin{tikzpicture}
\begin{axis}[view={60}{30},
axis lines=center,axis on top,
zmin=0, zmax=8,
xmin=-2,xmax=2,
ymin=-2,ymax=2,
width=6cm,height=6cm]
\addplot3+[no markers,line width=2pt,color=orange,domain=0:10*pi,samples=80,samples y=0]
({sin(deg(x))},
{cos(deg(x))},
{2*x/(5*pi)});
\end{axis}
\end{tikzpicture}
答案1
您需要更改参数化以便使用:
{2*x/(5*pi)},
{sin(deg(x))},
{cos(deg(x))}
这使得螺旋沿着x
轴线旋转。
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={60}{30},
axis lines=center,axis on top,
zmin=-2, zmax=2,
xmin=-2,xmax=8,
ymin=-2,ymax=2,
width=6cm,height=6cm]
\addplot3+[no markers,line width=2pt,color=orange,domain=0:10*pi,samples=80,samples y=0]
(
{2*x/(5*pi)},
{sin(deg(x))},
{cos(deg(x))}
);
\end{axis}
\end{tikzpicture}
\end{document}
仅用于演示,这是“其他”方向(沿轴y
)
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={60}{30},
axis lines=center,axis on top,
zmin=-2, zmax=2,
xmin=-2,xmax=2,
ymin=-2,ymax=8,
width=6cm,height=6cm]
\addplot3+[no markers,line width=2pt,color=orange,domain=0:10*pi,samples=80,samples y=0]
(
{sin(deg(x))},
{2*x/(5*pi)},
{cos(deg(x))}
);
\end{axis}
\end{tikzpicture}
\end{document}