I am trying to annotate my ggplot figure with some text but I struggle to find an optimal solution. I want to create a margin to the right of the figure so that I can write Course A, Course B and Course C. Now I don't have enough space. I have tried to use plot.margin = unit(c(1,4,1 ,1), "cm") but that doesn't seem to give me space that I can use to annotate the plot. Is there a function in ggplot that I can use?
trainingplot <- ggplot(aggreg.data, aes(x = trainingblock, y = performance)) +
scale_y_continuous(name = "Time substracted from straight gliding time (sec.)", breaks = seq(-2, 6, 1)) +
scale_x_discrete() +
theme_pubr()+
theme(legend.position="none",
axis.title.x=element_blank(),
plot.margin = unit(c(1,4,1 ,1), "cm")) +
geom_hline(aes(yintercept = 0), linetype = "dashed", size=0.2) +
annotate("text", x = 5.4, y = -0.4, label = "Course A", size=4) +
annotate("text", x = 5.4, y = 0.5, label = "Course B", size=4) +
annotate("text", x = 5.4, y = 2, label = "Course C", size=4)