我知道如何在乳胶上生成方形网格,但我想知道是否有办法在图像中绘制带有给定标签 ($R_1$、$N$ 和 $R_2$) 的集合?我还想看看是否有办法绘制此图片中看到的绿线和蓝线。
我能够生成图表所需的点
\begin{tikzpicture}
\clip (-1,-1) rectangle (6cm,6cm);
\foreach \x in {1,2,3,4}
{
\foreach \y in {0,1,2}
{
\node[draw,circle,inner sep=1pt,fill] at (.5*\x,.5*\y) {};
}
}
\foreach \x in {0,5}{
\foreach \y in {1}{
\node[draw,circle,inner sep=1pt,fill] at (.5*\x,.5*\y) {};
}
}
\end{tikzpicture}
但我正在努力添加蓝线和绿线以及标签。
答案1
我将为每个节点命名\node(name)[...] {label}
,然后画线并添加标签。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\foreach \x in {1,...,4}{
\foreach \y in {0,...,2}{
\node(circ-\x-\y)[draw,circle,inner sep=1pt,fill] at (.5*\x,.5*\y) {};
}
}
\foreach \x in {0,5}{
\foreach \y in {1}{
\node(circ-\x-\y)[draw,circle,inner sep=1pt,fill] at (.5*\x,.5*\y) {};
}
}
% lines
\foreach \i [evaluate=\i as \j using int(\i+1)] in {2,...,4}{
\draw[green!50!black] (circ-1-0) -- (circ-\i-2);
\draw[blue!50!black] (circ-1-0) -- (circ-\j-1);
}
% labels
\node[right] at ($(circ-5-1) - (0,0.5)$) {$\mathrm{R_2}$};
\node[right] at (circ-5-1) {$\mathrm{N}$};
\node[right] at ($(circ-5-1) + (0,0.5)$) {$\mathrm{R_1}$};
\end{tikzpicture}
\end{document}