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

I'd like to draw a square with the fill color darkening as one goes up or as one goes to the right. So, the square should be darkest in the upper-right corner and lightest in the lower-left corner. Is there a way to do this using PGF commands?

share|improve this question
up vote 5 down vote accepted

Such shadings are described in section 85.2 of the TikZ manual. Here's an example of what you want:

{color(0bp)=(white); color(80bp)=(black)} 



share|improve this answer
Thanks so much, exactly what I wanted! I was looking at an old user guide from 2004. – arnab Jan 2 '11 at 1:30

Another possibility is using tikz commands:

\tikz\shade[shading=axis,bottom color=black!10,top color=black,shading angle=-45] 
  (0,0) rectangle (3,3);
share|improve this answer
How could be set rectangle border line parameters? I tried ... (0,0) rectangle[line ...] (3,3), but error occured. – jafan Sep 29 '12 at 12:39
@jafan: take a look at \shadedraw – ted Jun 23 '13 at 19:21

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.