I need to generate a figure comprising 3 successive tikz pictures with vertical spacing in between. I've tried the following code:
\begin{figure}[h]
\caption{Cross-Validation with Three-Segmented Training Dataset}
\vspace{0.5 cm}
\begin{tikzpicture}
\node[text width=3cm] (Iteration 1)
{Iteration 1};
\node [draw,
minimum width = 2cm,
minimum height = 1cm,
fill = green!30!, right = 0.5cm of Iteration 1, rectangle] (Segment 1) {Training};
\node [draw,
minimum width = 2cm,
minimum height = 1cm, fill = green!30!, rectangle, right = 0.1cm of Segment 1] (Segment 2) {Training};
\node [draw,
minimum width = 2cm,
minimum height = 1cm, fill = red!30!, rectangle, right = 0.1cm of Segment 2] (Segment 3) {Testing};
\end{tikzpicture}
\vspace{0.25 cm}
\begin{tikzpicture}
\node[text width=3cm] (Iteration 2)
{Iteration 2};
\node [draw,
minimum width = 2cm,
minimum height = 1cm,
fill = red!30!, right = 0.5cm of Iteration 2, rectangle] (Segment 1) {Testing};
\node [draw,
minimum width = 2cm,
minimum height = 1cm, fill = green!30!, rectangle, right = 0.1cm of Segment 1] (Segment 2) {Training};
\node [draw,
minimum width = 2cm,
minimum height = 1cm, fill = green!30!, rectangle, right = 0.1cm of Segment 2] (Segment 3) {Training};
\end{tikzpicture}
\vspace{0.25 cm}
\begin{tikzpicture}
\node[text width=3cm] (Iteration 3)
{Iteration 3};
\node [draw,
minimum width = 2cm,
minimum height = 1cm,
fill = green!30!, right = 0.5cm of Iteration 3, rectangle] (Segment 1) {Training};
\node [draw,
minimum width = 2cm,
minimum height = 1cm, fill = red!30!, rectangle, right = 0.1cm of Segment 1] (Segment 2) {Testing};
\node [draw,
minimum width = 2cm,
minimum height = 1cm, fill = green!30!, rectangle, right = 0.1cm of Segment 2] (Segment 3) {Training};
\end{tikzpicture}
\centering
\end{figure}
but
is not correct. Why are the \vspace{0.25cm} commands not working in between the first and second tikz pictures (Iteration 1 and Iteration 2 respectively) as desired? Please offer the easiest/simplest solution. Thank you in advance.


\par\vskip\floatsepbetween rows of images/subfigures. Inside a figure,\parskip=0pt. – John Kormylo Sep 27 '23 at 16:00[right = 0.5cm of Iteration 1]because all I get is an error.? – John Kormylo Sep 27 '23 at 19:54positioninglibrary. – Qrrbrbirlbel Sep 27 '23 at 20:37