The ggridges package lets you draw ridgeplots with either solid colour:
ggplot(iris, aes(x=Sepal.Width, y=Species))+
geom_density_ridges(alpha=0.33, scale=2, fill="#0570b0", colour=alpha(0.1))+
theme_classic()
or with horizontal colour gradients:
ggplot(iris, aes(x=Sepal.Width, y=Species, fill=..x..))+
geom_density_ridges_gradient(scale=2,colour=alpha(0.1))+
theme_classic()+
scale_fill_gradient(low="#0570b0", high="White")
But I want to know if it is possible to produce a similar chart with a vertical colour gradient, like this example (which was drawn using D3.js). Is there a way to implement something similar in R?
Image source ONS: Middle-aged generation most likely to die by suicide and drug poisoning