我在一个圆上放置了 3 个节点。这些节点形状不同。我想将它们连接起来,并让箭头看起来像一个圆圈,因为这是一个重复的过程。
我可以用 连接它们bend left
,但对我来说这还不够圆。我可以用in=...
和来折腾out=...
,但这不是一个明智的解决方案,因为每次我想要这样的图片时,我都必须折腾。
下面是一个示例代码:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
% three differently shaped nodes on a circle
\node [rectangle, draw, text width=3cm] (a) at (180:3cm) {Hello World! Hello World!};
\node [rectangle, draw, text width=2cm] (b) at (60:3cm) {Hello World!};
\node [rectangle, draw, text width=2cm] (c) at (300:3cm) {Hello World!};
% connectors between the nodes
\draw[->] (a) to [bend left] (b);
\draw[->] (b) to [bend left] (c);
\draw[->] (c) to [bend left] (a);
% the circle I wish the connectors to be placed on
\draw[dashed,red] circle [radius=3cm];
\end{tikzpicture}
\end{document}
我希望连接器直接放在红色虚线圆圈上。有没有比尝试和纠错更聪明的解决方案in
?out
答案1
有没有人有比反复尝试更聪明的解决方案?
是的,尝试用bend left
参数出错:-)
% connectors between the nodes
\draw[->] (a) to [bend left=55] (b);
\draw[->] (b) to [bend left=55] (c);
\draw[->] (c) to [bend left=55] (a);
答案2
您可以得到交点,但较低级别的 PGF 弧值得这样做,因为这样您就可以给出弧的起点/终点。否则,我认为 JLDiaz 的答案足以让您摆脱困境。或者您只需将节点放在圆圈上,然后稍后放置箭头。但这些对我来说似乎都有些过头了。
\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}
\begin{document}
\begin{tikzpicture}
% three differently shaped nodes on a circle
\node [rectangle, draw, text width=3cm,name path=n1] (a) at (180:3cm) {Hello World! Hello World!};
\node [rectangle, draw, text width=2cm,name path=n2] (b) at (60:3cm) {Hello World!};
\node [rectangle, draw, text width=2cm,name path=n3] (c) at (300:3cm) {Hello World!};
% the circle I wish the connectors to be placed on
\path[name path=c] circle (3cm);
\path[name intersections={of=n1 and c,name=i1},
name intersections={of=n2 and c,name=i2},
name intersections={of=n3 and c,name=i3}
];
\begin{scope}
\pgfpathmoveto{\pgfpointanchor{i1-1}{center}}
\pgfsetarrowsend{to}
\pgfpatharcto{3cm}{3cm}{0}{0}{0}{\pgfpointanchor{i2-1}{center}}
\pgfusepath{draw}
\pgfpathmoveto{\pgfpointanchor{i2-2}{center}}
\pgfpatharcto{3cm}{3cm}{0}{0}{0}{\pgfpointanchor{i3-1}{center}}
\pgfusepath{draw}
\pgfpathmoveto{\pgfpointanchor{i3-2}{center}}
\pgfpatharcto{3cm}{3cm}{0}{0}{0}{\pgfpointanchor{i1-2}{center}}
\pgfusepath{draw}
\end{scope}
\end{tikzpicture}
\end{document}
答案3
只是为了展示smartdiagram
。
这是代码
\documentclass{article}
\usepackage{smartdiagram}
\begin{document}
\smartdiagramset{text width = 3cm, circular distance=3cm}
\smartdiagram[circular diagram]{Hello World! Hello World!, Hello World!, Hello World!}
\end{document}
这就是结果
这很简单,但是:
- 所有节点具有相同的特征(文本宽度、最小尺寸……)
- 连接圈不够