如何使用 R 中的 tmap 将图例放置在构面下方?
How can I place the legend below the facets using tmap in R?
这是一个可重现的例子
library(tmap)
data("World")
tm_shape(World) +
tm_polygons("pop_est", style = "cont", legend.is.portrait=FALSE) +
tm_facets("continent") +
tm_layout(legend.position = c("left", "bottom"),
main.title = "Population",
main.title.position = "centre")
我希望将图例放置在小平面下方,以便更好地使用 space 并使所有内容更加居中。我有什么想法可以做到这一点吗?
您可以尝试将图例放在绘图之外并将其居中:
data("World")
tm_shape(World) +
tm_polygons("pop_est", style = "cont", legend.is.portrait = FALSE) +
tm_facets("continent") +
tm_layout(legend.outside = TRUE,
legend.outside.position = "bottom",
legend.position = c(0.25, 0.25),
main.title = "Population",
main.title.position = "centre")
这是一个可重现的例子
library(tmap)
data("World")
tm_shape(World) +
tm_polygons("pop_est", style = "cont", legend.is.portrait=FALSE) +
tm_facets("continent") +
tm_layout(legend.position = c("left", "bottom"),
main.title = "Population",
main.title.position = "centre")
我希望将图例放置在小平面下方,以便更好地使用 space 并使所有内容更加居中。我有什么想法可以做到这一点吗?
您可以尝试将图例放在绘图之外并将其居中:
data("World")
tm_shape(World) +
tm_polygons("pop_est", style = "cont", legend.is.portrait = FALSE) +
tm_facets("continent") +
tm_layout(legend.outside = TRUE,
legend.outside.position = "bottom",
legend.position = c(0.25, 0.25),
main.title = "Population",
main.title.position = "centre")