13

I have 3 nodes placed on a circle. These nodes are differently shaped. I want to connect them and want the arrows to look like a circle, because it is a repeating process.

I can connect them with bend left, but that is not circle enough for me. I could mess around with in=... and out=..., but that is not a smart solution, because I would have to mess around every time I want such a picture.

Here an example code:

\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}

I would like the connectors to be placed directly on the red dashed circle. Has anyone a smarter solution than try and error with in and out?

HeLLo
  • 515

3 Answers3

12

Has anyone a smarter solution than try and error with in and out?

Yes, try and error with bend left argument :-)

result

% 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);
JLDiaz
  • 55,732
9

You can get the intersections but lower level PGF arcs make it worth doing it because then you can give start/end points of the arc. Otherwise I think JLDiaz' answer is good enough to get away. Or you simply put your nodes on a circle and place arrow heads later. But these all seem overkill to me.

\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}

enter image description here

percusse
  • 157,807
  • This is what I pointed to in my comment, though you can do it with let … in and the arc operator without the need to use PGF at all. Putting it inside a \foreach makes it a little bit easier to maintain. – Qrrbrbirlbel Mar 21 '13 at 19:06
  • @Qrrbrbirlbel Yes I saw that after posting the answer but you need to compute the start/end angles with respect to center of the circle.Instead you copy paste 3 times. But still I think manual approach is the proper one. foreach is a good idea I forgot that. – percusse Mar 21 '13 at 19:08
8

Just to show how easy is with smartdiagram.

This is the code

\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}

and this is the result

enter image description here

It's easy but:

  • all nodes share same characteristics (text width, minimum size, ...)
  • connections are not circle enough
Ignasi
  • 136,588
  • The problem with smartdiagram is that the diagrams it produces are totally lacking in style. Every imaginable feature seems to be enabled by default, and the result looks like a naïve first foray into PowerPoint. It's usually poor design to combine borders, shadows, gradient backgrounds and multicoloured items in a single diagram, but it's surprisingly hard to disable all these features. But none of this is criticism of you for a helpful alternative answer, so thank you for posting it. – richard Aug 11 '22 at 12:17