将节点发送到前端 tikz

将节点发送到前端 tikz

像我这样的尼安德特人一样,我选择在 tikz 中制作以下图表:

\begin{tikzpicture}
\draw[fill=blue] (-1,0) circle (3pt);
\draw[fill=blue] (-1,0.5) circle (3pt);
\draw[fill=blue] (-1,1) circle (3pt);
\draw[fill=blue] (-1,1.5) circle (3pt);
\draw[fill=blue] (-1,2) circle (3pt);
\draw[fill=red] (1,0.25) circle (3pt);
\draw[fill=red] (1,0.75) circle (3pt);
\draw[fill=red] (1,1.25) circle (3pt);
\draw[fill=red] (1,1.75) circle (3pt);
\draw[thin] (-1,0) -- (1,0.25) -- (-1,0.5) -- (1,0.75) -- (-1, 1) -- (1,1.25) -- (-1, 1.5) -- (1, 1.75) -- (-1,2) -- (1,1.25) -- (-1,0.5) -- (1,1.75) -- (-1,1) -- (1,0.25) -- (-1,2) -- (1,0.75) -- (-1,0) -- (1, 1.75);
\draw[thin] (-1,0) -- (1,1.25);
\draw[thin] (-1,1.5) -- (1,0.25);
\draw[thin] (-1,1.5) -- (1,0.75);
\end{tikzpicture}

但是,这给我带来了一个小问题,但相当烦人,即线条位于节点之上,并且图形看起来并不像它应该的那样好。有没有一种简单的方法可以将节点放在前面?

答案1

最简单的方法可能是改变代码中命令的顺序。

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[thin] (-1,0) -- (1,0.25) -- (-1,0.5) -- (1,0.75) -- (-1, 1) -- (1,1.25) -- (-1, 1.5) -- (1, 1.75) -- (-1,2) -- (1,1.25) -- (-1,0.5) -- (1,1.75) -- (-1,1) -- (1,0.25) -- (-1,2) -- (1,0.75) -- (-1,0) -- (1, 1.75);
\draw[thin] (-1,0) -- (1,1.25);
\draw[thin] (-1,1.5) -- (1,0.25);
\draw[thin] (-1,1.5) -- (1,0.75);
\draw[fill=blue] (-1,0) circle (3pt);
\draw[fill=blue] (-1,0.5) circle (3pt);
\draw[fill=blue] (-1,1) circle (3pt);
\draw[fill=blue] (-1,1.5) circle (3pt);
\draw[fill=blue] (-1,2) circle (3pt);
\draw[fill=red] (1,0.25) circle (3pt);
\draw[fill=red] (1,0.75) circle (3pt);
\draw[fill=red] (1,1.25) circle (3pt);
\draw[fill=red] (1,1.75) circle (3pt);
\end{tikzpicture}
\end{document}

相关内容