I'm trying to produce a multi-panel figure to map the different maritime facades of France. A basic reproducible example is:
library(rnaturalearth)
library(tidyverse)
library(ggpubr)
ggarrange(ggplot() +
geom_sf(data = ne_countries(scale = "small", returnclass = "sf")) +
coord_sf(xlim = c(-6, 3),
ylim = c(48.5, 52)),
ggplot() +
geom_sf(data = ne_countries(scale = "small", returnclass = "sf")) +
coord_sf(xlim = c(-10, -1),
ylim = c(43, 48.5)),
ggplot() +
geom_sf(data = ne_countries(scale = "small", returnclass = "sf")) +
coord_sf(xlim = c(3, 10),
ylim = c(41, 44)),
ncol = 1)
I can't find a solution to align my different panels so that they have the same width, without distorting the aspect ratio of each panel. Basically, I want each panel to be, e.g., 8cm wide, with a varying height so that each map is not distorted.
I've tried align = "h"
, but it does not work: I get similar widths but the ratios are distorted.
I have also tried multiple other things, such as exporting each panel with a set width, to then extract the ratio of each figure and then use relative heights in ggarrange()
, but it does not work either.
Would you have a solution for this?
library(rnaturalearth)
library(tidyverse)
library(patchwork)
patchwork::wrap_plots(
ggplot() +
geom_sf(data = ne_countries(scale = "small", returnclass = "sf")) +
coord_sf(xlim = c(-6, 3),
ylim = c(48.5, 52)),
ggplot() +
geom_sf(data = ne_countries(scale = "small", returnclass = "sf")) +
coord_sf(xlim = c(-10, -1),
ylim = c(43, 48.5)),
ggplot() +
geom_sf(data = ne_countries(scale = "small", returnclass = "sf")) +
coord_sf(xlim = c(3, 10),
ylim = c(41, 44)),
ncol = 1)