I'd like to make a geom_area
plot with the fill colour based on the y
(or any other) value, similar to the geom_density_ridges_gradient
function of the ggridges
package. I could achieve this with multiple geom_col
s but I want to have the nice smooth geom_area
style. Do you have any idea?
This code illustrates what I want to do:
data <- data.frame(x = 1:100,
y = rnorm(100, 20,3))
#I'd like to have an area plot with the fill colour based on the y values
ggplot(data = data, aes(x = x, y = y))+
geom_area(aes(fill = y))
#As in a bar plot, but with a smooth area, not a composite of rectangles
ggplot(data = data, aes(x = x, y = y))+
geom_col(aes(fill = y))
Thanks a lot!