I am trying to plot 2 scatterplots on top of each other, but I want to have the same limits on the x-axis so that the two plots are aligned.
I tried:
p1 <- ggplot(mtcars, aes(x=wt, y=mpg)) +
geom_point() +
scale_x_continuous(limits = c(0,10))
plot(1:10)
p2 <- recordPlot()
plot_grid(p1,p2,
labels = 'AUTO',
hjust = 0, vjust = 1,
nrow=2)
Is there a way to automatically set the x-limits? For example if I were to have another plot (say a barplot with long labels in the y-axis). Can this be achieved?