I made a violin graph using rtruncnorm and a set of data and annotated it. This is my plot code:
ggplot(g) +
annotate(geom = "rect", xmin = -Inf , xmax = Inf , ymin = 0, ymax = 1, fill = "red", alpha= 0.4) +
annotate(geom = "rect", xmin = -Inf , xmax = Inf , ymin = 1, ymax = max(g$PGR), fill = "green", alpha= 0.4) +
geom_violin(aes(x=1, y=PGR), fill=NA , color="darkred") +
geom_boxplot(aes(x=1, y=PGR) , width = 0.01) +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())
and received this plot: Violin Plot
I want to use annotate to fill the shape made by the violin plot. So I only want the area inside the "violin" annotated. any suggestions? clues?
Thanks for any help :)