答案1
因为你似乎想要有阴影,所以在 Ti 中绘制整个东西可能会更容易钾Z。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc,matrix,shadows.blur,decorations.pathreplacing}
\tikzset{shadowed/.style={decorate,decoration={
show path construction,
lineto code={
\draw[#1!50!gray,opacity=0.5] ([xshift=0.5ex,yshift=-0.25ex]\tikzinputsegmentfirst) -- ([xshift=0.5ex,yshift=-0.25ex]\tikzinputsegmentlast);
\draw[#1] (\tikzinputsegmentfirst) -- (\tikzinputsegmentlast);
}}}}
\begin{document}
\begin{tikzpicture}[buffy/.style={circle,draw,inner sep=3pt,fill=#1,blur shadow}]
\matrix[matrix of nodes,nodes={align=center,anchor=center},row sep=4pt] (mat)
{ $x_1$ & $x_2$ & $x_3$\\
|[buffy=blue]| & |[buffy=blue]| & |[buffy=blue]|\\
|[buffy=blue]| & |[buffy=blue]| & |[buffy=gray]|\\
|[buffy=blue]| & |[buffy=gray]| & |[buffy=blue]|\\
|[buffy=blue]| & |[buffy=gray]| & |[buffy=gray]|\\
|[buffy=gray]| & |[buffy=blue]| & |[buffy=blue]|\\
|[buffy=gray]| & |[buffy=blue]| & |[buffy=gray]|\\
|[buffy=gray]| & |[buffy=gray]| & |[buffy=blue]|\\
|[buffy=gray]| & |[buffy=gray]| & |[buffy=gray]|\\
};
\path ($(mat-1-1.north east)!0.5!(mat-1-2.north west)$) coordinate (auxL)
($(mat-1-2.north east)!0.5!(mat-1-3.north west)$) coordinate (auxR)
($(mat-1-1.south west)!0.5!(mat-2-1.north west)$) coordinate (auxT);
\draw[shadowed=black] (auxL |- mat.north) -- (auxL |- mat.south)
(auxR |- mat.north) -- (auxR |- mat.south)
(auxT -| mat.west) -- (auxT -| mat.east);
\begin{scope}[thick]
\foreach \X in {5,7,8,9}
{\draw[shadowed=red] (mat-\X-1.center -| mat.west) -- (mat-\X-3.center -| mat.east);}
\end{scope}
\end{tikzpicture}
\end{document}