这应该相当容易,但我找不到我的方式.
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轴的渐变,但是上面我只得到一个带有渐变的图例和带有实心填充的多边形.