简体   繁体   English

在 tmap 中对齐图例标题

[英]Align Legend Title in tmap

Is it possible to center the legend title in tmap ?是否可以在tmap中将图例标题tmap Utilizing the first example from the tmap getting started vignette :利用tmap 入门小插图中的第一个示例:

library(tmap)
data("World")

tm_shape(World) +
  tm_polygons("HPI") 

yields产量

在此处输入图片说明

but I want:但我想要:

在此处输入图片说明

I have scoured the documentation for tm_layout but can't figure out how to align the text of the legend title.我已经搜索了tm_layout的文档,但无法弄清楚如何对齐图例标题的文本。 It seems that the only options for legend.title in tm_layout are (1) legend.title.color , (2) legend.title.size , (3) legend.title.fontface , and (4) legend.title.fontfamily , none of which control the alignment.似乎legend.titletm_layout的唯一选项是(1) legend.title.color ,(2) legend.title.size ,(3) legend.title.fontface ,和(4) legend.title.fontfamily ,没有一个控制对齐。 Am I missing something obvious?我错过了一些明显的东西吗?

Well... aparently there is not an argument to control the location of the legend title, have you considered report this as an issue?嗯......显然没有控制图例标题位置的参数,您是否考虑过将其报告为问题?

A workaround though could be:一种解决方法可能是:

library(tmap)
data("World")

tm_shape(World) +
  tm_polygons("HPI", 
              title = "     HPI")

Yes, I know how ugly this looks, but it gets you the result.是的,我知道这看起来有多难看,但它会让你得到结果。

在此处输入图片说明

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

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