我有一堆直线,我只想在任意位置(比如在端点)放置大圆点,颜色连续(红、蓝、红、蓝)。我尝试过,但无法从网上获得任何帮助。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw (0,0) -- (0,4);
\draw (0.3,0) -- (0.3,4);
\draw (0.8,0) -- (0.8,4);
\draw (1.1,0) -- (1.1,4);
\draw (1.6,0) -- (1.6,4);
\draw (1.9,0) -- (1.9,4);
\node[anchor=west] at (axis cs:18.5,-0.019){\textbullet};
\end{tikzpicture}
\end{document}
这是我的失败尝试
答案1
实心圆圈
该示例将端点命名1bot
为和6bot
,1top
以便6top
更容易地独立于实际坐标对它们进行着色。
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw
\foreach[count=\i] \x in {0, 0.3, 0.8, 1.1, 1.6, 1.9} {
(\x, 0) coordinate (\i bot) -- (\x, 4) coordinate (\i top)
}
;
\fill[red, radius=2pt]
\foreach \i in {1, ..., 6} {
(\i bot) circle[]
}
;
\fill[blue, radius=2pt]
\foreach \i in {1, ..., 6} {
(\i top) circle[]
}
;
\end{tikzpicture}
\end{document}
地块标记
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw
\foreach[count=\i] \x in {0, 0.3, 0.8, 1.1, 1.6, 1.9} {
(\x, 0) coordinate (\i bot) -- (\x, 4) coordinate (\i top)
}
;
\path plot[mark=*, mark options=red] coordinates {
(1bot) (2top) (3bot) (4top) (5bot) (6top)
};
\path plot[mark=*, mark options=blue] coordinates {
(1top) (2bot) (3top) (4bot) (5top) (6bot)
};
\end{tikzpicture}
\end{document}
此外,线条还可以着色(根据评论):
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[red]
\foreach[count=\i] \x in {0, 0.8, 1.6} {
(\x, 0) coordinate (r\i bot) -- (\x, 4) coordinate (r\i top)
}
;
\draw[blue]
\foreach[count=\i] \x in {0.3, 1.1, 1.9} {
(\x, 0) coordinate (b\i bot) -- (\x, 4) coordinate (b\i top)
}
;
\path plot[mark=*, mark options=red] coordinates {
(r1bot) (b1top) (r2bot) (b2top) (r3bot) (b3top)
};
\path plot[mark=*, mark options=blue] coordinates {
(r1top) (b1bot) (r2top) (b2bot) (r3top) (b3bot)
};
\end{tikzpicture}
\end{document}