Does anyone know if the coloring in ggridges::geom_ridges_density_gradient can be controlled by a third variable?
To explain, if I draw a ridge diagram of wind directions in Lincoln NE (modified from an example in help(geom_ridges_density_gradient))
, I can color according
to x (here wind direction) or y (month). For instance the following produces a nice graphic showing a prevalence of NW winds from late fall to early spring, and SE winds during other months.
ggplot(lincoln_weather, aes(x = `WindDir [Degrees]`, y = `Month`, fill = stat(x))) +
geom_density_ridges_gradient(bandwidth=22.5) +
scale_fill_viridis_c(name = "Temp. [F]", option = "C") + xlim(0,360)
What would be neat is to color this according to the average windspeed per (month times direction). Just adding the wind speed as a fill variable does not do the job, but returns a gray monocolor image.
ggplot(lincoln_weather, aes(x = `WindDir [Degrees]`, y = `Month`, fill = (`Mean Wind Speed[MPH]`))) +
geom_density_ridges_gradient(bandwidth=22.5) +
scale_fill_viridis_c(name = "Wind direction (°)", option = "C") + xlim(0,360)
I cannot find examples where the colorscale is controlled by something other than fill=stat(x)
or fill=stat(y)
I don't understand the fill=stat
business well enough to advance on this. Does anyone know of examples where the coloring is done via a third variable?
Any help appreciated.