在三维图中绘制(透明)平面后面的分割轨迹

在三维图中绘制(透明)平面后面的分割轨迹

我有一条 3d 坐标轨迹,我将其分成两条独立的路径,一条路径带有负分量x_1,一条路径带有正分量x_1。如何在第一条轨迹前绘制一个(透明)平面?绘制顺序似乎没有影响。

梅威瑟:

\documentclass[]{article}

% Packages
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}  % For vertical plane

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
        width = 70mm,
        height = 65mm,
        xmin = -1,
        xmax = 1,
        ymin = -1,
        ymax = 1,
        zmin = -1,
        zmax = 1,
    ]
        % Draw the trajectory in the back
        \addplot3[draw=blue, unbounded coords=jump] coordinates {(-0.5,-0.5,0) (-0.5,0.5,0) (-0.1,0.5,0) (-0.1,-0.5,0)};
        % Draw a vertical plane
        \addplot3[name path=toppath, opacity=0, fill opacity=0, domain=-1:1] (0,y,1);
        \addplot3[name path=botpath, opacity=0, fill opacity=0, domain=-1:1] (0,y,-1);
        \addplot[color=red, faceted color=red, opacity=0, fill opacity=1] fill between[of=toppath and botpath];
        % Draw the trajectory in the front
        \addplot3[draw=blue, unbounded coords=jump] coordinates {(0.5,0.5,0) (0.5,-0.5,0) (0.1,-0.5,0) (0.1,0.5,0)};
    \end{axis}
\end{tikzpicture}

\end{document}

结果:

绘图结果

任何帮助都将非常感谢,谢谢!

答案1

如果我理解正确的话,您在寻找这个吗?

\documentclass{standalone}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween} 

\begin{document}

\begin{tikzpicture}
    \begin{axis}[
        width = 70mm,
        height = 65mm,
        xmin = -1,
        xmax = 1,
        ymin = -1,
        ymax = 1,
        zmin = -1,
        zmax = 1,
    ]
         
        \addplot3[draw=blue, unbounded coords=jump] coordinates {(-0.5,-0.5,0) (-0.5,0.5,0) (-0.1,0.5,0) (-0.1,-0.5,0)};
     
        \fill[name path=toppath, red, fill opacity=0.5] (axis cs:0,-1,-1) -- (axis cs:0,1,-1) -- (axis cs:0,1,1) -- (axis cs:0,-1,1) -- cycle;
     
        \addplot3[draw=blue, unbounded coords=jump] coordinates {(0.5,0.5,0) (0.5,-0.5,0) (0.1,-0.5,0) (0.1,0.5,0)};
    \end{axis}
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容