# Generate a square color matrix in Latex with TikZ

How can we generate this type of image using tikz package?

Thank you all

• probably, you can use some pieces from here tex.stackexchange.com/questions/274219/… Jun 22 '16 at 15:17
• what kind of data do you want to generate it from ? Jun 22 '16 at 15:26
• As there seems to be no colour pattern, you can do that with a simple tabular environment and the \cellcolor command from colortbl. Needless to summon TikZ for that. Jun 22 '16 at 15:26
• @ Amit : in that codes, there is a black borders and I want to fill all the squares with the same color as in the image posted here. @ Christoph: There is not a data, just I want to find a code that gives me the image Jun 22 '16 at 15:41
• See this question. Shouldn't be hard to adapt to your situation. Jun 22 '16 at 16:23

If the color pattern is given by a mathematical function, you might want to plot it using the pgfplots colormap.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[view={0}{90}]
\end{axis}
\end{tikzpicture}
\end{document}


• There's also the matrix plot style in PGFPlots, which makes the squares centered on the coordinates (in your examples, the colour values of the squares represent the average of the four corner values)
– Jake
Jun 22 '16 at 19:13

An example with TiKZ and a colorseries from xcolor.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\pgfmathsetseed{1}
\begin{tikzpicture}
\definecolorseries{test}{rgb}{step}[rgb]{.95,.85,.55}{.17,.47,.37}
\resetcolorseries[35]{test}
\foreach \x in {0,1,...,4}{
\foreach \y in {0,1,...,7}
\fill[test!!+] (\x,\y) rectangle ++(1,1);
}
\end{tikzpicture}
\end{document}