What I'm trying to do is to draw to 4 x 4 grids side-by-side to represent the concept of bootstrap, from statistics.
So, what I would like to do is to draw them and fill each cell of each grid with a random color chosen from a predefined set of colors.
After that, I would like to connect the grids with an arrow centered on the y middle of them with and the x positioned at the right and left border of them, respectively.
This is an example of what I would like to achieve:
This is my current approach:
\documentclass[11pt,a4paper]{article}
\usepackage{tikz}
\begin{figure}[htb]
\begin{tikzpicture}[scale=.7]
\begin{scope}
\draw (0, 0) grid (4, 4);
\coordinate (input);
\end{scope}
\begin{scope}[xshift=7cm]
\draw (0, 0) grid (4, 4);
\coordinate (output);
\end{scope}
\draw[-latex, thick, red!80] (input) -- (output) node [pos=0.5,above,font=\footnotesize] {output};
\end{tikzpicture}
\end{figure}
\end{document}
However, I'm far from what I would like:
How should I proceed?
Thank you.
Best Answer
I would suggest you use the
to
syntax instead of the--
for connecting the squares. For coloring the squares you can define a list of colors via\pgfmathdeclarerandomlist
:Notes:
tikz
'scalc
library to get the midpoint of the squares.Code: