我正在尝试绘制此图表,并希望将文本放置在网格中的每个单元格中,以便方向与网格相同。这可能吗?
这是我的代码:
\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
如果我理解你的问题,也许可以这样
\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}