Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Arrow between two nodes in two different tikzpictures

I have a tikzpicture where I use two def blocks to define two unique figures. I want to draw an arrow between two nodes and each of them locate in each def block. There are IDs assigned to each node, but the arrow I get is not what I want.

\usetikzlibrary{shapes}
\usetikzlibrary{math}

\def\clusterone{%
\begin{tikzpicture}[scale=1.0]
    \foreach \radius [count=\angleCount from 0] in {0.2, 0.6, 0.4, 0.5}
        {\node[draw=green, circle, inner sep=0pt, minimum size=2pt, fill=green] (c1-\angleCount) at ({\radius * cos(90 * \angleCount)}, {\radius * sin(90 * \angleCount)}) {};}
\end{tikzpicture}%
}

\def\clustertwo{%
\begin{tikzpicture}[scale=1.0]
    \foreach \radius [count=\angleCount from 0] in {0.6, 0.1, 0.4, 0.6}
        {\node[draw=green, circle, inner sep=0pt, minimum size=2pt, fill=green] (c2-\angleCount) at ({\radius * cos(90 * \angleCount)}, {\radius * sin(90 * \angleCount)}) {};}
\end{tikzpicture}%
}

\scalebox{1}{
\begin{tikzpicture}
    \node[rotate=30] (node1) at (0, 1.5) {\clusterone};
    \node[] at (0, 1.5) {1};
    \node[rotate=30] (node2) at (0, 0) {\clustertwo};
    \node[] at (0, 0) {2};
    
    \draw[->] (c1-0) -- (c2-3);
\end{tikzpicture}
}
Expected Current Result
expected current

Is there a way to address IDs of two nodes that are located inside two different tikzpictures? Or is there a way to draw an arrow between nodes in this situation?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Don’t nest tikz pictures!

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{math}

\begin{document}

\def\clusterone{%
    \foreach \radius [count=\angleCount from 0] in {0.2, 0.6, 0.4, 0.5}
        {\node[draw=green, circle, inner sep=0pt, minimum size=2pt, fill=green] (c1-\angleCount) at ({\radius * cos(90 * \angleCount)}, {\radius * sin(90 * \angleCount)}) {};}
}

\def\clustertwo{%
    \foreach \radius [count=\angleCount from 0] in {0.6, 0.1, 0.4, 0.6}
        {\node[draw=green, circle, inner sep=0pt, minimum size=2pt, fill=green] (c2-\angleCount) at ({\radius * cos(90 * \angleCount)}, {\radius * sin(90 * \angleCount)}) {};}
}

\begin{tikzpicture}
  \begin{scope}[yshift=1.5cm]
    \clusterone
  \end{scope}
  \node[] at (0, 1.5) {1};
  \begin{scope}
    \clustertwo
  \end{scope}
  \node[] at (0, 0) {2};
  \draw[->] (c1-0) -- (c2-3);
\end{tikzpicture}

\end{document}

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading