Re: [R] is it possible to fill with a color or transparency gradient?

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri 06 Oct 2006 - 21:51:50 GMT

> I haven't been using R very long, so it's possible that I'm just
> missing something, but I haven't found anything like this in the help
> files. I've tried to poke around in graphics, grid, and ggplot,
> without any luck so far. I really like some of the functionality in
> ggplot, and it does some nice things with continuous gradients for the
> color of scatter plot points, for example, but it each individual
> point (or grob) is always one solid color as far as I can tell.

ggplot supports alpha blending provided your graphics device does too (Quartz on the mac, or pdf version 1.3 or later). Have a look at the alpha function for easily making transparent colours, as well as scgradient for specifying the colour scale.

Oh, I see you want a gradient fill on a polygon - that's a lot harder, and I can only suggest dividing your polygon up into smaller rectangles and filling those individually. That appears to be what gradient.rect does.

Hadley



R-help@stat.math.ethz.ch 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 Sat Oct 07 07:56:45 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 06 Oct 2006 - 22:30:11 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.