pgfplots-带有覆盖线的三维图

pgfplots-带有覆盖线的三维图

你好呀

绘制的某些 3D 图形中pgfplots有应该隐藏的线和平面,但却显示在前面的线和平面前面,如何解决这个问题?

梅威瑟:

\documentclass{article}

\usepackage{pgfplots}

\pgfplotsset{
    compat  = newest,
    width   = 10cm,    % width
    height  =  7cm,    % height
    samples = 10,
}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        % Hiperbole
        \addplot3 [
            % Aparence
            surf,
            opacity      = 0.5,
            fill opacity = 1,
            faceted color = white,
            shader = faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            variable   = \u,
            variable y = \v,
            domain   = -1:1,
            domain y = 0:360,
        ](
            {cosh(u)*cos(v)},
            {cosh(u)*sin(v)},
            {sinh(u)}
        );
    
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        % Elipse
        \addplot3 [
            % Aparence
            surf,
            opacity=0.5,
            fill opacity= 1,
            faceted color = white,
            shader=faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            variable   = \u,
            variable y = \v,
            domain   = 0:360,
            domain y = -180:0,
        ]
        (
            {cos(u)*sin(v)}, 
            {sin(u)*sin(v)}, 
            {cos(v)}
        );
    
    \end{axis}
\end{tikzpicture}

\end{document}

生成以下图片,没有标明问题的青色注释: 打印生成的 PDF 并指出问题所在

答案1

您可以对 z 缓冲区进行排序 -z buffer=sort

\documentclass{article}

\usepackage{pgfplots}

\pgfplotsset{
    compat  = newest,
    width   = 10cm,    % width
    height  =  7cm,    % height
    samples = 10,
}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        % Hiperbole
        \addplot3 [
            % Aparence
            surf,
            opacity      = 0.5,
            fill opacity = 1,
            faceted color = white,
            shader = faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            variable   = \u,
            variable y = \v,
            domain   = -1:1,
            domain y = 0:360,
             z buffer=sort,
        ](
            {cosh(u)*cos(v)},
            {cosh(u)*sin(v)},
            {sinh(u)}
        );
    
    \end{axis}
\end{tikzpicture}
\begin{tikzpicture}
    \begin{axis}[hide axis]
        
        % Elipse
        \addplot3 [
            % Aparence
            surf,
            opacity=0.5,
            fill opacity= 1,
            faceted color = white,
            shader=faceted interp,
            % Scope
            data cs = cart, % cart/polar/polarrad
            % Variable
            variable   = \u,
            variable y = \v,
            domain   = 0:360,
            domain y = -180:0,
             z buffer=sort,
        ]
        (
            {cos(u)*sin(v)}, 
            {sin(u)*sin(v)}, 
            {cos(v)}
        );
    
    \end{axis}
\end{tikzpicture}

\end{document}

双曲面和球面

相关内容