如何自定义 3D 图

如何自定义 3D 图

在这个墨西哥帽子势的 3d 图中,我怎样才能使后部比前部进一步向上延伸(如蓝线所示),以免过多地阻碍最小值圆? 在此处输入图片描述  

\documentclass[svgnames]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
    
\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
            axis lines=center,
            axis equal,
            domain=0:360,
            y domain=0:1.25,
            y axis line style=stealth-,
            y label style={at={(0.325,0.15)}},
            xmax=1.75,ymax=1.5,zmax=1.5,
            xlabel = $\varphi_1$,
            ylabel=$\varphi_2$,
            zlabel=$U_k(\rho)$,
            ticks=none,
        ]
        
        \addplot3 [surf,shader=flat,draw=black,fill=white,z buffer=sort] ({sin(x)*y}, {cos(x)*y}, {(y^2-1)^2});
        \end{axis}
        \fill[DarkBlue] (3.05,3.4) circle (0.1) coordinate (center);
        \fill[DarkRed] (4.7,2) circle (0.1) coordinate (minimum);
        \draw[LightGray,line width=0.8,shorten <=5,shorten >=5] (center) edge[out=-15,in=150,->] (minimum);
    \end{tikzpicture}
\end{document}

答案1

您可以使用选项指定查看绘图的角度。此外,您应该在轴环境内定义和view={phi}{theta}的坐标,然后在外部绘制它们。(center)(minimum)

\documentclass[svgnames]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            axis lines=center,
            axis equal,
            domain=0:360,
            y domain=0:1.25,
            y axis line style=stealth-,
            y label style={at={(0.325,0.15)}},
            xmax=1.75,ymax=1.5,zmax=1.5,
            xlabel = $\varphi_1$,
            ylabel=$\varphi_2$,
            zlabel=$U_k(\rho)$,
            ticks=none,
            view={30}{35}
        ]

            \addplot3 [surf,shader=flat,draw=black,fill=white,z buffer=sort] ({sin(x)*y}, {cos(x)*y}, {(y^2-1)^2});
            \coordinate (center) at (axis cs:0,0,1);
            \coordinate (minimum) at (axis cs:{cos(30)},{sin(30)},0);
        \end{axis}
        \fill[DarkBlue] (center) circle (0.1);
        \fill[DarkRed] (minimum) circle (0.1);
        \draw[LightGray,line width=0.8,shorten <=5,shorten >=5] (center) edge[out=-15,in=150,->] (minimum);
    \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容