ggplot: How to produce a gradient fill within a geom_polygon
问题 This should be fairly easy but I can't find my way thru. 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") What I want is a gradient along the x-axis, but with the above I only get