I have encountered some unexpected behavior in the tmap
library and was wondering if there is a way around it. When producing a map with an expression in the legend title, the legend becomes too wide for some reason.
Here's some code to show what I mean:
library(tmap)
data("World")
# Produces normal legend window
tm_shape(World) +
tm_polygons("HPI") +
tm_layout(legend.bg.color = "#AAAAAA")
# Produces wide legend window
title <- expression(Local~G[i]^"*")
tm_shape(World) +
tm_polygons("HPI", title = title) +
tm_layout(legend.bg.color = "#AAAAAA")
I tried using the legend.width
parameter of tm_layout
, but that messes up the font and symbol size down the line. Any ideas how to fix this? Thanks!