Hello,
I would like to build a grid and to specify the color of each cell. The grid is very large so I want to do it with file data. I have absolutely no idea of how to do it. Do you have any idea ?
The idea is to obtain in LaTeX what you obtain with Excel when you use the conditional formatting on a grid of values. Here I do not want to draw the values, but only the corresponding color (there is no place to write the numbers.)
Thank you in advance.
Graphics, Figures & Tables ⇒ Grid with colored Cells
NEW: TikZ book now 40% off at Amazon.com for a short time.

Grid with colored Cells
Hello,
I've tried several ways, and in the end, it turned out to be easier in this way:
However, it is difficult to show more than 5000 cells (=5000 lines of data).
To increase the number of cells that I can show, I used a gray to white gradient color. Thus, I show gray and light gray cells, but there is no need to specify the white cells, which correspond then to the background.
Hope it helps someone else.
Bye
I've tried several ways, and in the end, it turned out to be easier in this way:
Code: Select all
\pgfmathsetmacro{\minval}{0}
\pgfmathsetmacro{\maxval}{2}
\pgfmathsetmacro{\colstep}{100/(\maxval-\minval)}
\begin{tikzpicture}[scale=0.3]
\foreach \x/\y/\z in {
1/0/1,
22/0/1,
40/0/1,
53/0/1,
...
187/99/1
}
{
\pgfmathsetmacro{\ptcol}{\colstep*(\z-\minval)}
\fill[gray!\ptcol!white] (\x/4-0.25,\y/4-0.25) rectangle (\x/4,\y/4);
}
\draw (-0.25,-0.25) rectangle (200/4-0.25, 100/4-0.25);
\end{tikzpicture}
To increase the number of cells that I can show, I used a gray to white gradient color. Thus, I show gray and light gray cells, but there is no need to specify the white cells, which correspond then to the background.
Hope it helps someone else.
Bye