TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I fill a grid in TikZ? I want to do something like:

\draw[draw,fill=red!20] (0,0) grid (2,2);

instead of manually drawing 4 rectangles.

share|improve this question
up vote 9 down vote accepted

Unfortunately not a direct solution, but you can just append a rectangle operation going back to the origin of the grid:


\draw [ultra thick, draw=black, fill=black!20!white] (0,0) grid  (2,2) rectangle (0,0);

filled grid tikz

share|improve this answer
In this case you can have some problem. The rectangle is drawn, the line width is the same for the grid and the rectangle. – Alain Matthes Jun 18 '11 at 10:17
@Altermundus: That's correct, but it's not a very problematic behaviour. – Jake Jun 18 '11 at 11:03

I think no but perhaps I am wrong. One rectangle is enough:

  \fill[red!20](0,0) rectangle (2,2); 
  \draw (0,0) grid (2,2);
share|improve this answer

With PSTricks. Unfortunately PSTricks' grid has no options for changing

  • the fill color
  • the line style

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.