0

I'm trying to connect the ends of child nodes in TikZ. The lines form the correct shape (it should look like a triangle), but they are appearing weirdly displaced. I want the lines to connect the nodes, not appear way out from the graph.

When I comment out the \tikz line, it seems to resolve the problem. Why is this? How can I fix it while keeping it formatted like this?

enter image description here

\begin{tikzpicture}
    \tikzstyle{level 1}=[sibling angle=120]
    \tikzstyle{level 2}=[sibling angle=60]
    \tikzstyle{level 3}=[sibling angle=30]
    \tikzstyle{every node}=[fill]
    \tikz [grow cyclic,shape=circle,very thick,level distance=13mm,cap=round]
    \node (root) {} child [color=\A, name = \A] foreach \A in {red,green,blue}
    { node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
        { node {} 
        }
    };
\draw (root-1-1) -- (root-1-2) -- (root-1-3) -- (root-1-1);

\end{tikzpicture}

  • https://tex.stackexchange.com/questions/427258/tikz-mindmap-combine-grow-cyclic-with-clockwise-from – js bibra Feb 11 '21 at 04:14
  • Basically: do not nest tikzpictures (\tikz ...; is the same as \begin{tikzpicture}...;\end{tikzpicture}) https://tex.stackexchange.com/a/66037/38080 – Rmano Feb 11 '21 at 07:22
  • Thank you for the explanation, I didn't know \tikz... is the same as \begin{tikzpicture}, or that nesting it could cause issues! I appreciate it :) – ComputeMe Feb 11 '21 at 18:19

1 Answers1

0
\begin{tikzpicture}
    \tikzstyle{level 1}=[sibling angle=120]
    \tikzstyle{level 2}=[sibling angle=60]
    \tikzstyle{level 3}=[sibling angle=30]
    \tikzstyle{every node}=[fill]
    \path [grow cyclic,shape=circle,very thick,level distance=13mm,cap=round]%<------change \tikz to \path
    node (root) {} child [color=\A, name = \A] foreach \A in {red,green,blue}
    { node {} child [color=\A!50!\B] foreach \B in {red,green,blue}
        { node {} 
        }
    };

    \draw (root-1-1) -- (root-1-2) -- (root-1-3) -- (root-1-1);
\end{tikzpicture}
js bibra
  • 21,280
  • 2
    Find Wally! Jokes apart, I humbly suggest that you comment what you have changed and why... it is not easy to spot that you changed \tikz to \path, unless you know why... – Rmano Feb 11 '21 at 07:50