I am trying to create a figure showing three violinplots on top of each other (on the same x label) in a "pre" condition, and the same for a "post" condition.
With this script:
library(ggplot2)
library(ggbreak)
Elbow=fakebis$Elbow
Wrist=fakebis$Wrist
Tip_of_middle_finger=fakebis$`Tip of middle finger`
Time=fakebis$Time
data<-data.frame(Elbow,Wrist,Tip_of_middle_finger,Time)
positions <- c("Pre", "Post")
p <- ggplot(data, aes(Time, Elbow))+
theme_classic() +
xlab("Measurment time relative to tool-use session")+
scale_x_discrete(limits = positions)+
scale_y_break(c(4, 27))+
ylab("Reported position (cm)")
p <- p + geom_violin(aes(colour = "1"), alpha = .5, size=2,trim=FALSE)+
geom_boxplot(width=0.1)+
geom_jitter(shape=16, position=position_jitter(0.2))
q <- p + geom_violin(aes(y = Wrist, colour = "2"), alpha = .5, size=2,trim=FALSE)+
geom_boxplot(width=0.1)+
geom_jitter(shape=16, position=position_jitter(0.2))
q <- q + geom_violin(aes(y = Tip_of_middle_finger, colour = "3"), alpha = .5, size=2,trim=FALSE)+
geom_boxplot(width=0.1)+
geom_jitter(shape=16, position=position_jitter(0.2))
q
I obtain this plot:
I don't understand why the boxplots and the data points are not plotted over the green and blue violins...
Thanks in advance for your help :) !