I am trying to add a vertical centered title to my colorbar legend but it stacks the title on top of the colorbar instead of the the right. I have tried adding position = "right" but it does not help, i have tried vjust, hjust it does not work either.
The plot it produces:
what I would like:
Code:
ggplot(df, aes(x=img_type, y=metric),show.legend = FALSE) +
geom_point(aes(size = abs_corr, colour=corr))+scale_size(range =c(-0.1,20) )+
scale_colour_gradient2(
low = "#7e1952",
high = "#2f7a9a",
space = "Lab",
na.value = "white",
guide = "colourbar",
aesthetics = "colour",
mid = "white",
limits=c(-1,1), name = "Spearman's Correlation Coefficient"
)+ guides(size = "none")+
theme(legend.key.height = unit(2.5, "cm"))+
guides(fill = guide_colourbar(label.position = "right"))+
theme(legend.title = element_text(size = 12, angle = 90) )
Data:
metric pval corr img_type abs_corr
1 aes 0.0000 0.6820 T2_TSE 0.6820
2 aes 0.0000 0.7365 T2_FLAIR 0.7365
3 aes 0.0003 0.2412 T1_MPR 0.2412
4 aes 0.0000 0.3510 T1_TIRM 0.3510
5 tg 0.0000 0.4434 T2_TSE 0.4434
6 tg 0.0000 0.8093 T2_FLAIR 0.8093
7 tg 0.0000 0.2813 T1_MPR 0.2813
8 tg 0.0000 0.3513 T1_TIRM 0.3513
9 coent 0.0028 -0.2583 T2_TSE 0.2583
10 coent 0.0008 -0.4210 T2_FLAIR 0.4210