大小:您需要指定size.max
给两个变量共同引用。
图例:没有直接的方法——你不能将c(TRUE, FALSE)
向量传递给legend.size.show
,要么两者都有,要么都没有。您需要使用 custom 的解决方法grid
。
下面的代码:
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))