Size: You need to specify size.max
to give both variables common reference.
Legend: there is no straightforward way -- you cannot pass c(TRUE, FALSE)
vector to legend.size.show
, it's either both or none. You need to use a workaround with custom grid
.
Code below:
library(grid)
library(tmap)
tmap_mode("plot")
data(NLD_muni)
max_size <- max(c(NLD_muni$origin_non_west, NLD_muni$origin_native))
nld_plot_native <- tm_shape(NLD_muni) +
tm_borders() +
tm_bubbles(
size = "origin_native",
size.max = max_size,
legend.size.is.portrait = TRUE,
legend.size.show = TRUE
)
nld_plot_non_west <- tm_shape(NLD_muni) +
tm_borders() +
tm_bubbles(
size = "origin_non_west",
size.max = max_size,
legend.size.is.portrait = TRUE,
legend.size.show = FALSE
)
grid.newpage()
pushViewport(viewport(layout = grid.layout(1, 2)))
print(nld_plot_native, vp = viewport(layout.pos.col = 1))
print(nld_plot_non_west, vp = viewport(layout.pos.col = 2))