1

I am trying to plot this diagram and I want to place text in each of the cells in the grids so that the orientation is the same as the grid. Is this possible?

enter image description here

Here is my code:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
    \pgftransformcm{1}{0.5}{0}{1}{\pgfpoint{0cm}{0cm}}
    
    \draw[black, line width=1.5pt, fill=gray!10] (0,0) rectangle (4,4);
    \draw[step=0.5cm,black!20] (0,0) grid (4,4);

    \node[align=center] at (2,1) {\rotatebox{90}{Rotated Text}};
    
    
    \draw[blue, line width=1.5pt, fill=blue!5] (4.5,-1) rectangle (6,0.5);
    \draw[step=0.5cm,blue!20] (4.4999,-1) grid (6,0.5);

    \draw[black, dotted, line width=1.5pt, fill=gray!10] (6.5,-5) rectangle (10.5,-1);
    \draw[step=0.5cm,black!20] (6.5, -5) grid (10.5,-1);
    \draw[black, dotted, line width=1.5pt,] (6.5,-2.5) rectangle (8,-1);
    \draw[-, thick] (1.5, 4) -- (8, -1);
    \draw[-, thick] (0, 2.5) -- (6.5, -2.5);
    
    \draw[red, line width=1.5pt,] (7,-2) rectangle (7.5,-1.5);
    \draw[red, line width=1.5pt,] (0.5,3) rectangle (1,3.5);
    \draw[red, line width=1.5pt,] (5,-0.5) rectangle (5.5,0);

    \draw[-, red] (1, 3) -- (7.5, -2);
    \draw[-, red] (0.5, 3) -- (7, -2);
    \fill[red, opacity=0.1] (1,3) -- (7.5,-2) -- (7,-2) -- (0.5,3) -- cycle;

    \draw[-, red] (1, 3) -- (7.5, -2);
    \draw[-, red] (1, 3.5) -- (7.5, -1.5);
    \fill[red, opacity=0.1] (1,3) -- (7.5,-2) -- (7.5,-1.5) -- (1,3.5) -- cycle;

    \draw[-, red] (0.5, 3) -- (7, -2);
    \draw[-, red] (0.5, 3.5) -- (7, -1.5);
    \fill[red, opacity=0.1] (0.5,3) -- (7,-2) -- (7,-1.5) -- (0.5,3.5) -- cycle;

    \draw[-, red] (0.5, 3.5) -- (7, -1.5);
    \draw[-, red] (1, 3.5) -- (7.5, -1.5);
    \fill[red, opacity=0.1] (0.5,3.5) -- (7,-1.5) -- (7.5,-1.5) -- (1,3.5) -- cycle;

\end{tikzpicture}
\caption{temp caption}
\end{figure}

\end{document}
1
  • feels like a job for \node[transform shape]
    – JeT
    Commented Apr 3 at 18:46

1 Answer 1

0

If i get your question right, maybe something like

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}
    \pgftransformcm{1}{0.5}{0}{1}{\pgfpoint{0cm}{0cm}}
    
    \draw[black, line width=1.5pt, fill=gray!10] (0,0) rectangle (4,4);
    \draw[step=0.5cm,black!20] (0,0) grid (4,4);
    
    \foreach \x in {0,...,7}{
        \foreach \y in {0,...,7}
        {
            \node[transform shape, rotate = 90, font=\tiny] at (\x*0.5+0.25,\y*0.5+0.25) {Text};
        }
    }    
    
    \draw[blue, line width=1.5pt, fill=blue!5] (4.5,-1) rectangle (6,0.5);
    \draw[step=0.5cm,blue!20] (4.4999,-1) grid (6,0.5);
    

    \draw[black, dotted, line width=1.5pt, fill=gray!10] (6.5,-5) rectangle (10.5,-1);
    \draw[step=0.5cm,black!20] (6.5, -5) grid (10.5,-1);
    \draw[black, dotted, line width=1.5pt,] (6.5,-2.5) rectangle (8,-1);
    \draw[-, thick] (1.5, 4) -- (8, -1);
    \draw[-, thick] (0, 2.5) -- (6.5, -2.5);
    
    \draw[red, line width=1.5pt,] (7,-2) rectangle (7.5,-1.5);
    \draw[red, line width=1.5pt,] (0.5,3) rectangle (1,3.5);
    \draw[red, line width=1.5pt,] (5,-0.5) rectangle (5.5,0);

    \draw[-, red] (1, 3) -- (7.5, -2);
    \draw[-, red] (0.5, 3) -- (7, -2);
    \fill[red, opacity=0.1] (1,3) -- (7.5,-2) -- (7,-2) -- (0.5,3) -- cycle;

    \draw[-, red] (1, 3) -- (7.5, -2);
    \draw[-, red] (1, 3.5) -- (7.5, -1.5);
    \fill[red, opacity=0.1] (1,3) -- (7.5,-2) -- (7.5,-1.5) -- (1,3.5) -- cycle;

    \draw[-, red] (0.5, 3) -- (7, -2);
    \draw[-, red] (0.5, 3.5) -- (7, -1.5);
    \fill[red, opacity=0.1] (0.5,3) -- (7,-2) -- (7,-1.5) -- (0.5,3.5) -- cycle;

    \draw[-, red] (0.5, 3.5) -- (7, -1.5);
    \draw[-, red] (1, 3.5) -- (7.5, -1.5);
    \fill[red, opacity=0.1] (0.5,3.5) -- (7,-1.5) -- (7.5,-1.5) -- (1,3.5) -- cycle;

\end{tikzpicture}
\caption{temp caption}
\end{figure}

\end{document}
2
  • That works great. So does "transform shape" enable the node to follow the transformation that was applied to the image?
    – Tatzz
    Commented Apr 4 at 7:54
  • @Tatzz take a look @tikzmanual
    – JeT
    Commented Apr 4 at 11:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .