1

I want to merge three subplots in with ggplot2. I know I can use gridspec_kw in matplotlib in python. Is there any similar way in ggplot2? For example, the range of x-axis of the plot 1 is (0,5), and the width of its x-axis is 5 cm. The range of x-axis of the plot 2 is (0,10), and the width of its x-axis must be 10 cm.

I use grid.arrange(plot1, plot2,plot3, ncol=3) to merge three subplots. How can I set the scale for x-axis to be equal for all subplots?

justin
  • 11
  • 1

1 Answers1

2

You could try {patchwork} package, which excels at doing these jobs. For your jobs this could work:

library(patchwork)
plot1 + plot2 + plot_layout(widths = c(1, 2))

See here for more details.

Liang Zhang
  • 753
  • 7
  • 20