I'm creating boxplots and scatterplots with ggplot2, then arranging them with ggarrange. It works well, but I've encountered a problem. I have outliers in the data and for better visual representation I've incorporated scale breaks.
For some reason these scale breaks disappear when I then use ggarrange. Is there a simple way to solve this?
Below I've included some code with simple vectors that shows the problem. These are boxplots only. The first window will have scale breaks, the second window does not, and in the third window (made with ggarrange) the scale break is gone.
library(ggplot2)
library(ggbreak)
library(ggpubr)
vec1 <- c(1:50, 500)
data <- data.frame(vec1)
vec2 <- c(10:60)
data2 <- data.frame(vec2)
windows()
a <-ggplot() +
geom_boxplot(data=data, aes(x="1", y=vec1)) + scale_y_break(c(100, 550)) + theme(legend.position="none")
a
windows()
b <-ggplot() +
geom_boxplot(data=data2, aes(x="1", y=vec2)) + theme(legend.position="none")
b
windows()
ggarrange(a, b, labels = c("A", "B"), ncol = 2)