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