如何使用 pgfplots 将 3D 图映射到平面?

如何使用 pgfplots 将 3D 图映射到平面?

在回答了 pgfplots 中的一个问题,要求绘制一个函数后,我思考如何将 3D 函数映射到平面上。类似于这一页但我无法找到任何解决方案。

这是我的函数及其输出。我想在 3d 图的 xy 平面中显示左侧图;或者在 xz 和 yz 平面上映射函数。

在此处输入图片描述

% pdflatex
\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
       \pgfmathdeclarefunction{F}{3}{\pgfmathparse{#1* exp(#2*#3)}}
\begin{axis}
        [
        smooth, grid=both,minor tick num=1,
        xlabel=$x$,ylabel=$y$,
        tick align=inside,
        samples=1000,
        samples y=0,
        ]

        \addplot [solid, thick, data cs=polarrad, domain=0:10*pi] {F(5,-0.1,x)};
\end{axis}
\end{tikzpicture}
~
\begin{tikzpicture}
       \pgfmathdeclarefunction{F}{3}{\pgfmathparse{#1* exp(#2*#3)}}
\begin{axis}
        [smooth, grid=both,minor tick num=1,
        xlabel=$x$,ylabel=$y$,zlabel=$z$,
        samples=1000,
        samples y=0,
        ]

        \addplot3+
        [solid, thick, black,
        mark=none,
        thick,
        domain=0:10*pi,
        ]
        ({F(5,-0.1,x)*cos(deg(x))},{F(5,-0.1,x)*sin(deg(x))},{F(5,-0.1,x)});
\end{axis}
\end{tikzpicture}
\end{document}

答案1

感谢 Jake他的评论,我绘制了我想要的图形。由于包含四个图形,因此图形看起来有点丑陋;但是除了三维形状图之外,显示映射函数也很不错。此外,绘制此类图形的重点是用户应注意二维图的侧壁位于哪个坐标。在下面的图中,在 z=0 处,存在 xy 平面;在 y=4 处,存在 xz 平面;在 x=-4 处,存在 yz 平面。

在此处输入图片描述

% pdflatex
\documentclass[margin=2mm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
       \pgfmathdeclarefunction{F}{3}{\pgfmathparse{#1* exp(#2*#3)}}
\begin{axis}
        [smooth, grid=both,minor tick num=1,
        xlabel=$x$,ylabel=$y$,zlabel=$z$,
        samples=1000,
        samples y=0,
        domain y=0:6
        ]

        \addplot3+
        [dashed, black,thick,
        mark=none,
        thick,
        domain=0:25*pi,
        ]
        ({F(5,-0.1,x)*cos(deg(x))},{F(5,-0.1,x)*sin(deg(x))},{F(5,-0.1,x)});

        \addplot3 [domain=0:25*pi,samples=500, samples y=0, black!50, smooth] ({F(5,-0.1,x)*cos(deg(x))},{F(5,-0.1,x)*sin(deg(x))},{0});
        \addplot3 [domain=0:25*pi,samples=500, samples y=0, red!50, smooth] ({F(5,-0.1,x)*cos(deg(x))},{4},{F(5,-0.1,x)});
        \addplot3 [domain=0:25*pi,samples=500, samples y=0, blue!50, smooth] ({-4},{F(5,-0.1,x)*sin(deg(x))},{F(5,-0.1,x)});
\end{axis}
\end{tikzpicture}
\end{document}

相关内容