简体   繁体   English

tmap:面板标签周围的控制框

[英]tmap: control frame around panel label

I'm trying to make two multiples of germany with no frames around the maps - this I managed to do.我试图在地图周围没有框架的情况下制作德国的两个倍数 - 我设法做到了。 However, each multiple should have a label and I can't figure out how to control the frame around the panel labels.但是,每个倍数都应该有一个标签,我不知道如何控制面板标签周围的框架。
Is there any way to control the label frames or do I have to switch to ggplot for that?有什么方法可以控制标签框架还是我必须为此切换到 ggplot?

library(sp)
library(tmap)
library(RColorBrewer)

ID <- 1:16

Anzahl <- sample(10:80, 16)
AnzahlVF <- sample(50:200, 16)
Arbeitsort <- as.data.frame(cbind(ID, Anzahl, AnzahlVF))

Arbeitsort$relAnzahl <- Arbeitsort$Anzahl / sum(Arbeitsort$Anzahl)
Arbeitsort$relAnzahlVF <- Arbeitsort$AnzahlVF / sum(Arbeitsort$AnzahlVF)

ger <- sp::merge(x = germany, y=Arbeitsort, by.x = "ID_1", by.y = "ID")

pal <- brewer.pal(8, "Purples")

tm_shape(ger)+
  tm_polygons(c("relAnzahl", "relAnzahlVF"), title = "students",
              palette = pal)+
  tm_layout(panel.labels = c("1. Map", "2. Map"),
            panel.label.bg.color = NA,
            legend.format = list(text.separator = "bis"),
            legend.outside = T,
            frame = F)+
  tm_legend(position = c("left", "top"))

So if I understand correctly, you would like to disable the panel label borders?所以如果我理解正确,您想禁用面板标签边框吗? There is no option for that yet.目前还没有选择。 In your case there are two tweaks:在您的情况下,有两个调整:

1 You can use the title argument instead of panel.labels , but this only works when the legend is placed inside the map. 1 您可以使用 title 参数代替panel.labels ,但这仅在图例放置在地图内时才有效。 So the tweak is to use disable the legend, and draw the legend separately with tm_layout(legend.only = TRUE) .所以调整是使用禁用图例,并使用tm_layout(legend.only = TRUE)单独绘制图例。

2 You can use tm_credits(c("1. Map", "2. Map"), position = c("center", "top")) , but then you'll have to increase the 3rd value of the inner.margins (tm_layout). 2 您可以使用tm_credits(c("1. Map", "2. Map"), position = c("center", "top")) ,但是您必须增加内部的第三个值。边距(tm_layout)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM