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

From: Paul Murrell <p.murrell_at_auckland.ac.nz>
Date: Wed, 09 Apr 2008 07:53:16 +1200

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/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive