Pgfplots 表面不隐藏背景标记

Pgfplots 表面不隐藏背景标记

我正在尝试绘制三角形上的函数,因此首先添加函数非零的三角形底边。然后在三角形角添加节点。最后,添加函数(在本例中为线性函数)。但是,正如您在图中看到的,背景标记并未隐藏在绘制的表面后面(而三角形底边隐藏在后面!)。有没有办法隐藏这个标记(不添加标记不是一种选择)。这是 MWE:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

\begin{axis}[
        variable=s,
        variable y=t,        
        axis line style={draw=none},
        ticks=none,
        ]
        
\def\triangleParamX{s)}
\def\triangleParamY{t*(1-s)}

% draw triangle
\addplot3[surf, domain=0:1,y domain=0:1, color=gray, opacity=1, fill opacity=1, draw opacity=0, faceted color=black, samples=2] (\triangleParamX,\triangleParamY,{0});

% add nodes
\addplot3[mark=*] 
coordinates {
    (0,0,0) % first corner
    (1,0,0) % second corner
    (0,1,0) % second corner
    (0,0,0) % first corner
};

% draw surface
\addplot3[surf,domain=0:1, samples=20] (\triangleParamX,\triangleParamY, {y});
    
\end{axis}
\end{tikzpicture}
\end{document}

产生

在此处输入图片描述

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
set layers, mark layer=like plot,
clip=false,
variable=s,
variable y=t,        
hide axis,
]
\def\triangleParamX{s)}
\def\triangleParamY{t*(1-s)}
\addplot3[surf, shader=flat, gray, domain=0:1, y domain=0:1, samples=2] (\triangleParamX,\triangleParamY,{0});
\addplot3[mark=*] coordinates{
(0,0,0)
(1,0,0)
(0,1,0)
} -- cycle;
\addplot3[surf, domain=0:1, samples=20] (\triangleParamX,\triangleParamY, {y});
\end{axis}
\end{tikzpicture}
\end{document}

阴影三角形和部分可见的点

答案2

我设法通过不带标记(平面上的圆圈)的绘图来解决我的问题:

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}

\begin{axis}[
        variable=s,
        variable y=t,        
        axis line style={draw=none},
        ticks=none,
        clip=false
        ]
        
\def\triangleParamX{s)}
\def\triangleParamY{t*(1-s)}

% draw triangle
\addplot3[surf, domain=0:1,y domain=0:1, color=gray, opacity=1, fill opacity=1, draw opacity=0, faceted color=black, samples=2] (\triangleParamX,\triangleParamY,{0});

% add nodes
\addplot3[mark=none] 
coordinates {
    (0,0,0) % first corner
    (1,0,0) % second corner
    (0,1,0) % second corner
    (0,0,0) % first corner
};

\draw[fill=black] (5,0,0) arc (0:360:5);
\draw[fill=black] (105,0,0) arc (0:360:5);
\draw[fill=black] (5,100,0) arc (0:360:5);


% draw surface
\addplot3[surf,domain=0:1, samples=20] (\triangleParamX,\triangleParamY, {y});
    
\end{axis}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容