我正在尝试绘制移动网络图。为此,我在 tikz 中创建了一个基站/蜂窝塔图。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
\foreach \x in {-0.75, -0.25, 0.25, 0.75} {
\draw[thick] (\x,0) -- (\x,0.5);
}
\draw[thick] (-0.75,0) -- (0.75,0);
\path[name path=left, draw, thick] (-0.75, -3) -- (-0.0625, 0);
\path[name path=right, draw, thick] (0.75, -3) -- (0.0625, 0);
\path[name path=int1] (-1, -0.625) -- (1, -0.625);
\path[name path=int2] (-1, -1.5) -- (1, -1.5);
\path[name path=int3] (-1, -2.5) -- (1, -2.5);
\path[name intersections={of=int1 and left,by=li1}];
\path[name intersections={of=int2 and left,by=li2}];
\path[name intersections={of=int3 and left,by=li3}];
\path[name intersections={of=int1 and right,by=ri1}];
\path[name intersections={of=int2 and right,by=ri2}];
\path[name intersections={of=int3 and right,by=ri3}];
\draw (li1) -- (ri1);
\draw (li2) -- (ri2);
\draw (li3) -- (ri3);
\draw (li1) -- (ri2);
\draw (li2) -- (ri1);
\draw (li2) -- (ri3);
\draw (li3) -- (ri2);
\end{tikzpicture}
\end{document}
有没有办法使用 tikz 图片作为节点的形状,以便我可以轻松地将其放置在更大的图表中?
答案1
欢迎!是的,当然你可以把它做成图片。你也不需要交叉点。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[pics/power pole/.style={code={
\draw[thick] \foreach \X in {0.25, 0.75} {(-\X,0.5) |- (\X,0) -- (\X,0.5)}
(-0.75, -3) -- (-0.0625, 0) coordinate[pos=0.175] (l3)
coordinate[pos=0.5] (l2) coordinate[pos=0.775] (l1)
(0.75, -3) -- (0.0625, 0) coordinate[pos=0.175] (r3)
coordinate[pos=0.5] (r2) coordinate[pos=0.775] (r1);
\draw (l1) -- (r1) (l2) -- (r2) (l3) -- (r3)
(l1) -- (r2) (l2) -- (r3) (l3) -- (r2) (l2) -- (r1);
}}]
\path pic{power pole};
\end{tikzpicture}
\end{document}