I want to make time based density plots of a variable for the factor water use management for the data set as follows
Seed(123)
ID = rep(c("BAU","IMP","SGR","CR"), each=25)
Time = rep (c(1,2,3,4,5), each = 20)
data <- data.frame( ID, Time, profits = runif(100,0,1))
I am using the following codes to make density plot for profits across IDs. or may be facet_wrap for group or time?
library(ggridges)
ggplot(
data, aes(x = profits, y=as.factor( Time), group = ID, fill=stat(x))) +
geom_density_ridges_gradient(scale = 3, size = 0.3, rel_min_height = 0.01) +
scale_fill_viridis_c(name = "Profits", option = "C") +
labs(title = 'Total Profits') + facet_wrap(~ID, scales = "free")+
theme_classic()
It gives nice density plots. But for the large data of million rows as I have originally; for instance as given below:
Seed(123)
ID = rep(c("BAU","IMP","SGR","CR"), each=5000)
Time = rep (c(1:1000), each = 20)
data <- data.frame( ID, Time, profits = runif(20000,0,1))
the codes give an untidy graph. Can we make factor of time say in interval of 20 each to make the graph understandable? or if any other faceting or wrapping can improve the visibility of graph. Please help Thanks