如何用渐变色填充下方(sp)线以下的区域?
这个例子是在Inkscape中绘制的 - 但我需要垂直渐变 - 不是水平的.
从零到正的间隔==从白色到红色.
从零到负的间隔==从白色到红色.

有没有可以做到这一点的包?
我编造了一些源数据....
set.seed(1)
x<-seq(from = -10, to = 10, by = 0.25)
data <- data.frame(value = sample(x, 25, replace = TRUE), time = 1:25)
plot(data$time, data$value, type = "n")
my.spline <- smooth.spline(data$time, data$value, df = 15)
lines(my.spline$x, my.spline$y, lwd = 2.5, col = "blue")
abline(h = 0)
Run Code Online (Sandbox Code Playgroud) 这应该相当容易,但我找不到我的方式.
tri_fill <- structure(
list(x= c(0.75, 0.75, 2.25, 3.25),
y = c(40, 43, 43, 40)),
.Names = c("x", "y"),
row.names = c(NA, -4L), class = "data.frame",Integrated=NA, Related=NA)
# install.packages("ggplot2", dependencies = TRUE)
require(ggplot2)
ggplot(data=tri_fill,aes(x=x, y=y))+
geom_polygon() +
scale_fill_gradient(limits=c(1, 4), low = "lightgrey", high = "red")
Run Code Online (Sandbox Code Playgroud)
我想要的是沿着x轴的渐变,但是上面我只得到一个带有渐变的图例和带有实心填充的多边形.