我只想在使用
tm_facets
时添加指南针和scale_bar一次。这是示例代码
library(tmap)
library(stars)
library(terra)
#Read some data
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = rast(tif)
#Plot it using tmap r package
tm_shape(x) +
tm_raster(style="quantile")+
tm_facets(nrow = 3) +
tm_layout(panel.labels = names(x),
legend.outside=T, legend.outside.position = "right",
legend.position= c("center", "center"),
legend.text.size = 1,
legend.format = list(digits = 2, text.separator = "-"))+
tm_compass(position = c("RIGHT", "BOTTOM"))+
tm_scale_bar(text.size = 1, position = c("RIGHT", "BOTTOM"))
正如您在输出中看到的,所有方面都有指南针和比例尺。如何仅在一个方面添加指南针和比例尺?
我可以通过这篇文章
的帮助来添加单个指南针和scale_barlibrary(tmap)
library(stars)
library(terra)
#Read some data
tif = system.file("tif/L7_ETMs.tif", package = "stars")
x = terra::rast(tif)
#Plot it using tmap r package
tm_shape(x) + tm_raster(style="quantile") + tm_facets(nrow = 3) +
tm_layout(panel.labels = names(x), attr.outside = T, attr.outside.position = "bottom", attr.just = "right",
legend.outside = T, legend.outside.position = "right",
legend.position = c("left", "top"),
legend.text.size = 0.8, legend.title.size = 0.9,
legend.format = list(digits = 2, text.separator = "-"))+
tm_compass(position = c("left", "top"))+
tm_scale_bar(text.size = 1, position = c("RIGHT", "top"))