我一直在尝试用点绘制的边来完成图片中的图形。(a)........(b)。我搜索了互联网但没有找到任何结果,你能帮我吗?这是我正在使用的代码。
\begin{figure}[H]
\centering
\begin{tikzpicture}
\node[ellipse,draw] (2) at (1,0.4) {$1$};
\node[ellipse,draw] (1) at (-1.5,0.4) {$2$};
\node[ellipse,draw] (7) at (-1.5,3.6){$3$};
\node[ellipse,draw] (8) at (-2.1,2){$4$};
\node[ellipse,draw] (9) at (2,3){$5$};
\node[ellipse,draw] (3) at (-6,0.5) {$6$};
\node[ellipse,draw] (4) at (-6.3,4) {$7$};
\node[ellipse,draw] (6) at (-8,1) {$8$};
\node[ellipse,draw] (10) at (-8.5,3.9){$9$};
\draw (1) -- (2);
\draw (7) -- (8);
\draw (8) -- (9);
\draw (8) -- (1);
\draw (9) -- (7);
\draw (2) -- (8);
\draw (2) -- (7);
\draw (2) -- (9);
\draw (1) -- (9);
\draw (1) -- (7);
\draw (10) -- (6);
\draw (10) -- (4);
\draw (4) -- (3);
\draw (6)--(4);
\draw (3)--(10);
\draw (6)--(3);
\end{tikzpicture}
\caption{Illustration}
\end{figure}
期望输出:
抱歉,画得不好。我知道如何画出弧形边缘。绘图示例:\draw (7) to [out=20,in=160,looseness=0.5] (10);
我只是想知道如何将其更改为点线,因为我在文档中没有找到这种类型的箭头(仅适用于部分边缘,而不是全部)。提前致谢 :)。
答案1
您只需添加一个选项,如[dashed]
,[dotted]
等等。
查看PGF TiKz 手册根据图形参数:线宽、线端和线连接,目前在第 174 页。手册是你最好的朋友,我建议你做里面的教程,因为它们对于初学者来说是一个很好的开始。
此外,我还将您的节点重命名,使其更符合逻辑。
\documentclass[margin=2cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\begin{tikzpicture}
\node[ellipse,draw] (1) at (1,0.4) {$1$};
\node[ellipse,draw] (2) at (-1.5,0.4) {$2$};
\node[ellipse,draw] (3) at (-1.5,3.6){$3$};
\node[ellipse,draw] (4) at (-2.1,2){$4$};
\node[ellipse,draw] (5) at (2,3){$5$};
\node[ellipse,draw] (6) at (-6,0.5) {$6$};
\node[ellipse,draw] (7) at (-6.3,4) {$7$};
\node[ellipse,draw] (8) at (-8,1) {$8$};
\node[ellipse,draw] (9) at (-8.5,3.9){$9$};
\draw (1)
edge (2)
edge (3)
edge (4)
edge (5);
\draw (2)
edge (3)
edge (4)
edge (5);
\draw (3)
edge (4)
edge (5);
\draw (4) -- (5);
\draw (6)
edge (7)
edge (8)
edge (9);
\draw (7)
edge (8)
edge (9);
\draw (8) -- (9);
\draw[dashed] (9) to[out=30,in=140,looseness=1] (3);
\end{tikzpicture}
\end{document}
答案2
正如我在评论中所说,您只需要将选项densely dotted
(例如)添加到您提议的最后一条\draw
命令中:
\draw[densely dotted] (7) to [out=20,in=160,looseness=0.5] (10);
我提出这个例子,其中我重命名了节点以便于阅读,并借助\foreach
命令绘制了边以减少代码。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{shapes.geometric} % ellipse nodes
\begin{document}
\begin{tikzpicture}
% pentagon nodes
\node[ellipse,draw] (1) at ( 1 ,0.4) {$1$};
\node[ellipse,draw] (2) at (-1.5,0.4) {$2$};
\node[ellipse,draw] (3) at (-1.5,3.6) {$3$};
\node[ellipse,draw] (4) at (-2.1,2) {$4$};
\node[ellipse,draw] (5) at ( 2 ,3) {$5$};
% quadrilateral nodes
\node[ellipse,draw] (6) at (-6 ,0.5) {$6$};
\node[ellipse,draw] (7) at (-6.3,4) {$7$};
\node[ellipse,draw] (8) at (-8 ,1) {$8$};
\node[ellipse,draw] (9) at (-8.5,3.9) {$9$};
% pentagon graph
\foreach\i[evaluate=\i as \ii using {int(\i+1)}] in {1,...,4} \foreach\j in {\ii,...,5}
\draw (\i) -- (\j);
% quadrilateral graph
\foreach\i[evaluate=\i as \ii using {int(\i+1)}] in {6,7,8} \foreach\j in {\ii,...,9}
\draw (\i) -- (\j);
% link between the two graphs
\draw[red,thick,densely dotted] (3) to [out=130,in=40] (9);
\end{tikzpicture}
\end{document}