[R] diagonally fill a rectangle with color gradient

Paul Murrell p.murrell at auckland.ac.nz
Tue Apr 8 21:53:16 CEST 2008


Hi


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 ... ?

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

Paul
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul at stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list