I have created a figure with ggplot2 that displays some data points of an experiment I have done. However, I can´t find a good solution for my text labels. Now, I am repeating "Acqusitition trial blocks" three times so I think it would be better to just write it once and then have 1, 2 and 3 at the tick points. But I can`t find a good solution to this problem. Optimally, I want the solution to have Acquisition trial blocks below 1, 2 and 3.
trainingplot <- ggplot(sample_descriptive, aes(x=trainingblock, y=pointEstimate)) +
theme_pubr() +
scale_y_continuous(name = "Time substracted from straight gliding time (sec.)", limits = c(-1, 5), breaks = c(-1, 0, 1, 2,3,4)) +
scale_x_discrete(expand = expansion(add = c(.6, 1.2)), labels= c("Pre-test", "Acquisition trial block\n 1", "Acquisition trial block\n 2", "Acquisition trial block\n 3", "Retention (72h)")) +
annotate("text", x = 5.5, y = -0.4, label = "Course A", size=4.5) +
annotate("text", x = 5.5, y = 0.5, label = "Course B", size=4.5) +
annotate("text", x = 5.5, y = 2, label = "Course C", size=4.5)
trainingplot <- trainingplot +
geom_errorbar(data = sample_descriptive, aes(x=trainingblock, y = pointEstimate, ymin = lower.CL,ymax = upper.CL, group=interaction(course, group)), position = position_dodge(0.2), size=1, width=0.3) +
geom_line(data = sample_descriptive, aes(x=trainingblock, y = pointEstimate, group=interaction(course, group)), position = position_dodge(0.2), alpha=0.4) +
geom_point(data = sample_descriptive, aes(x=trainingblock, y=pointEstimate, shape=group, fill=group, group=interaction(course, group)), position = position_dodge(0.2), size=2.8, color="black") +
theme(legend.position="none",
axis.title.x=element_blank()) +
geom_hline(aes(yintercept = 0), linetype = "dashed", size=0.2) +
scale_fill_manual(values = c("#1A85FF", "#D41159", "#FFB000")) +
scale_shape_manual(values=c(21, 24))