I use the following code to draw a tikz object.
\begin{tikzpicture}
% Axis
\draw (-0.5,0) -- (5.0,0);
\draw (0,-0.5) -- (0,2.5);
\node (rect) at (1.5,2) [draw,minimum height=0.65cm,minimum width=2cm,fill=gray!50] {};
\node (rect) at (2.5,1) [draw,minimum height=0.65cm,minimum width=3cm,fill=gray!50] {};
\end{tikzpicture}
and the object looks like -
What I would like to have is grid of such objects. So that in the grid at every location (1,1), (1,2)... (n,n) this object should be drawn.
Of course I can copy paste this code using scope and use xshift, yshift
in order to place many of them. What I need to see how 10 x 10
grid or even 100 x 100
grid of such objects. However I would like to use a for
loop to draw this grid of tikz nodes. I want to use the for loop mentioned in this question. However my tikz node consists of multiple nodes (2 lines and 2 rectangles).
Is it possible to draw the grid of objects using for loop?
matrix
library, and the corresponding section of the manual. Of course you can also use a\foreach
loop, wich can be more convenient of a large number of similar repeated nodes.