Hi

If the ribbon has constant "height" then this can be hacked by drawing a bunch of ribbons (polygons) with different heights and slowly changing colours. If the height of the ribbon varies, then you could use the same approach and clip the result, with a little bit more work. The attached code demonstrates the latter approach (the image files that it produces for me are also attached).

Hope that helps

Paul

On 11/05/17 08:05, Kristi Glover wrote:
Hi R Users,

I was trying to create a figure with geom_ribbon. There is a function
"fill", but I want to make the shaded area with a gradient
(increasing dark color towards a central line, inserted of having a
color). Is there any possibility?


In the given example, I want the colour with "blue" but in a gradient
(dark=central, light= as goes higher or lower)


pl = data.frame(Time = 0:10, menle = rnorm(11))

pl$menlelb = pl$menle -1

pl$menleub = pl$menle +1

ggplot(pl, aes(Time)) +

geom_line(aes(y=menle), colour="blue") +

geom_ribbon(aes(ymin=menlelb, ymax=menleub), fill="blue")


Thanks

[[alternative HTML version deleted]]

______________________________________________ R-help@r-project.org
mailing list -- To UNSUBSCRIBE and more, see
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.


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

Attachment: gradient.pdf
Description: Adobe PDF document

Attachment: ggplot.pdf
Description: Adobe PDF document

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to