I have been using ggplot geom_boxplot and arranging the x axis according to a specific order with scale_x_discrete resulting in a perfect plot. Then I try to arrange 4 of these plots using ggarrange, but that overrides the order of the groups. How can I do both? thank you
H_p<-ggplot (DiversData, aes(x=site, y=H, color=site)) +
geom_boxplot()
H_p + scale_x_discrete(limits=c("Achziv", "SdotYam", "Sharon", "Ashdod", "Ashkelon")) +labs(title="Shannon fish diversity", x = "", y = "H", color = "Site") + theme_classic() + theme(legend.position="none")
Then when I tile them:
library(ggpubr)
require(grid)
ggarrange(p_vis2 + rremove("x.text")+ rremove("xlab"), H_p + rremove("x.text")+ rremove("xlab"), S_p + rremove("x.text")+ rremove("xlab"), J_p + rremove("x.text")+ rremove("xlab"),
labels = c("A", "B", "C", "D"),
ncol = 2, nrow = 2,common.legend = TRUE, legend = "bottom",
align = "hv",
font.label = list(c("Achziv", "SdotYam", "Sharon", "Ashdod", "Ashkelon"),size = 10, color = "black", face = "bold", family = NULL, position = "top") )
The x axis goes back to ABC order
Thank you so much!