如何按照附图的样式绘制双曲抛物面

如何按照附图的样式绘制双曲抛物面

如何仅使用一种颜色绘制附图样式的双曲抛物面在此处输入图片描述

请修改我的代码

   \documentclass{article}
\usepackage{pgfplots}

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}
        \begin{axis}[
            xlabel=$x$,
            ylabel=$y$,
            zlabel=$z$,
            view={60}{30},
        ]
        \addplot3[surf, shader=interp, domain=-2:2, samples=41] 
            {x^2/4 - y^2/9};
        \end{axis}
    \end{tikzpicture}
    \caption{Hyperbolic Paraboloid: $z = \frac{x^2}{4} - \frac{y^2}{9}$}
\end{figure}

\end{document}

答案1

在此处输入图片描述

一个解决方案是将抛物面一分为二,以实现某种分层。我对坐标轴做了同样的事情。

pdfplots我根据@hpekristiansen 关于和坐标系兼容性的善意评论修改了代码tikz

代码

\documentclass[11pt, margin=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}

\begin{tikzpicture}
  \pgfplotsset{set layers}
  \begin{axis}view={150}{12}, axis lines=none]
    \addplot3[
    surf,
    colormap/cool,
    shader=flat,
    opacity=.6,
    domain=-4:4,
    domain y=-4:0,
    samples=40,
    clip=false
    ] {x^2 -y^2};

    % plane section x = 0
    \addplot3[%
    draw=blue, very thin,
    fill=red, fill opacity=.15,
    domain=-4:4,
    samples y=0
    ] (0, x, {-x^2});

    \draw[ultra thin, ->] (0, 0, 0) -- (6, 0, 0)
    node[below, text=black, scale=.8] {$x$};

    \addplot3[
    surf,
    colormap/cool,
    shader=flat,
    opacity=.6,
    domain=-4:4,
    domain y=0:4,
    samples=40,
    clip=false
    ] {x^2 -y^2};

    \addplot3[%
    draw=blue, very thin,
    domain=0:4,
    samples y=0
    ] (0, x, {-x^2});

    \draw[ultra thin, ->] (0, 0, 0) -- (0, 0, 18)
    node[above, text=black, scale=.8] {$z$};
    \draw[ultra thin, ->] (0, 0, 0) -- (0, 6, 0)
    node[below, text=black, scale=.8] {$y$};
  \end{axis}
\end{tikzpicture}

\end{document}

答案2

您显示的图像与计算出的双曲面不匹配。

请参阅 pgfplots 手册第 5.2 节(第 425 页)。

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colorbrewer}

\begin{document}

\begin{figure}
    \centering
    \begin{tikzpicture}
        \begin{axis}[
            xlabel=$x$,
            ylabel=$y$,
            zlabel=$z$,
            view={60}{30},
            colormap/PuBu-9
            ]
        \addplot3[surf, shader=interp, domain=-2:2, samples=41] 
            {x^2/4 - y^2/9};
        \end{axis}
    \end{tikzpicture}
    \caption{Hyperbolic Paraboloid: $z = \frac{x^2}{4} - \frac{y^2}{9}$}
\end{figure}

\end{document}

相关内容