I would like some help for the rainclouds plot again. Thanks to a previous question, I was able to make a raincloud plot with a histogram (thanks again). But I would like to know if it is possible to put a normality curve on these histograms. I tried with the stat_density() function but the curve does not appear. Same if I tried to replace the geom_histogram() function with this :
ggdensity(data, x = "blah", fill = "lightgray", title = "blah") +
scale_x_continuous(limits = c(0, 12)) +
stat_overlay_normal_density(color = "red", linetype = "dashed")
This is my code based on the last comment of tjebo:
po<-ggplot(data = data, aes(x = rt, y = -.15, fill = numlecteur, color=numlecteur)) + geom_histogram(aes(y = after_stat(count/100)), alpha = .2) +
stat_density(geom = "line") +
ggstance::geom_boxploth( width = .1, outlier.shape =NA, alpha = 0.1) +
guides(fill = FALSE, color = FALSE) + facet_wrap(~numlecteur, nrow = 4, scales = "free_y" , strip.position = "left") + theme(axis.title.y = element_blank(), axis.text.y = element_blank(),
axis.ticks.y = element_blank())
I have another question. Can we put all this code into a plotly-like animation? In fact I have several identical graphs that increase gradually so with an animation it would be less heavy and easier to understand than to have twenty graphs. I don't if it's clear but in the code, only "x=rt" change and the data of the several x only increase.
For the plotly I would like something like that :
hist<-ggplot(test, aes(x=Mesures, color=Rayons)) +
geom_histogram(fill="white", position="dodge")+
theme(legend.position="top")
ggplotly(hist)
But instead of having all the elements at once, I would like to have a cursor that I could drag to have the "r1", "r2" etc as I go.
(sources : https://peerj.com/preprints/27137v1.pdf Introducing Raincloud Plots! – Dr. Micah Allen)