Re: [R] diagonally fill a rectangle with color gradient

From: Paul Murrell <>
Date: Wed, 09 Apr 2008 07:53:16 +1200


tom soyer wrote:
> Hi,
> Is it possible to diagonally fill a rectangle with a color gradient? I
> noticed that the gradient.rect of plotrix could fill a rect either up and
> down or from side to side. I am looking for something similar but fills
> diagonally instead, e.g., from the upper left corner to the bottom right.
> Does anyone know how to do it in R?

Do you mean something like this ... ?


pushViewport(viewport(width=.5, height=.5, clip="on"))
pushViewport(viewport(width=2, height=2, angle=45))
grid.rect(y=100:1/100, just="top",
                  fill=colorRampPalette(c("blue", "green"),


Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
New Zealand
64 9 3737599 x85392

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 08 Apr 2008 - 20:36:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Apr 2008 - 21:30:34 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive