I have the following ggplot2
code that plots the ribbon from the 3rd to the 97th quartile:
h <- ggplot(l, aes(x=age[limit]))
h <- h + geom_ribbon(aes(ymin=X3rd[limit], ymax=X97th[limit]), fill="gray80")
h
The geom_ribbon help page suggests that gradient, gradient2, etc are 'related scales' for fill for this geom. What I'm after is to have the ribbon light grey on the outside, to darker grey in the middle then lighter grey again on the outside, but I get the impression (and some goo开发者_JAVA技巧gle results strengthen this impression) that the gradients can't actually be applied to ribbon.
geom_ribbon does not support gradient. Instead, if I correctly understand what you want to do, then overlapping ribbons may be useful:
d <- data.frame(x=1:10, m=runif(10))
d <- transform(d, l1=m-1, l2=m-2, u1=m+1, u2=m+2)
ggplot(d, aes(x)) +
geom_ribbon(aes(ymin=l2, ymax=u2), fill="grey60") +
geom_ribbon(aes(ymin=l1, ymax=u1), fill="grey40")
精彩评论