[R] creating a color gradient in geom_ribbon

Kristi Glover kristi.glover at hotmail.com
Wed May 10 22:05:24 CEST 2017


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]]



More information about the R-help mailing list