Building on this question, I am trying to do the exact same, but horizontally instead of vertically.
The solution accepted in the question doesn't seem to work when the alignment is vertical.
Can anyone explain why? And how to fix it?
Here's an example unsing egg
, as suggested in the answer to the original question.
dat1 <- data.frame(y = rep(1:10, 2), x = 1:20)
dat2 <- data.frame(x = 1:10, y = 1:10)
plot1 <- ggplot(dat1, aes(x = x, y = y)) + geom_point() + coord_equal()
plot2 <- ggplot(dat2, aes(x = x, y = y)) + geom_point() + coord_equal()
egg::ggarrange(plot1, plot2, nrow = 1)
Notice that the plot on the left lost its coord_equal in favour of the two plots having the same width.