简体   繁体   中英

Align Legend Title in tmap

Is it possible to center the legend title in tmap ? Utilizing the first example from the tmap getting started vignette :

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. 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. 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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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