![使用 tikz 或辫子线绘制的字符串交叉图](https://linux22.com/image/464377/%E4%BD%BF%E7%94%A8%20tikz%20%E6%88%96%E8%BE%AB%E5%AD%90%E7%BA%BF%E7%BB%98%E5%88%B6%E7%9A%84%E5%AD%97%E7%AC%A6%E4%B8%B2%E4%BA%A4%E5%8F%89%E5%9B%BE.png)
答案1
像这样:
代码:
\documentclass[a4paper]{article}
\usepackage{tikz}
\begin{document}
\thispagestyle{empty}
\begin{tikzpicture}[scale=.7]
\draw[gray!20] (-5,-5) grid (5,5); % <-- comment this line after seeiing the code
\draw[red,line width=2pt] (-4,-4)--(-4,4);
\draw[blue,line width=2pt] (-3,-4)--(-3,4);
\draw[blue,line width=2] (4,-4) arc (0:180:3);
\draw[blue,line width=2] (4,4) arc (0:-180:3);
\draw[red,line width=2pt] (.5,-4)--(.5,4);
\draw[red,line width=2pt] (1.5,-4)--(1.5,4);
\end{tikzpicture}
\end{document}
编辑:如果您希望在每条线弧的末尾添加彩色点,请在之前添加此行\end{tikzpicture}
:
\foreach \j in {-4,4}{
\foreach \i/\c in {-4/red,-3/blue,-2/blue,.5/red,1.5/red,4/blue}
\filldraw[\c] (\i,\j) circle(4pt);
}
新输出: