I would like to change the font for the main title of a thematic plot using the tmap package in R from 'plain' to italics but keep the font for the legend heading and text 'plain'.
However, when I change the argument fontface in the lm_layout() function it changes the font face of all text in the map. Is it possible to only change the font face for the main title in tmap?
My attempt at a reproducible example (which, unfortunately, changes the font face of all text in the map to italics) is below:
library(tmap)
data("World")
tm_shape(World) +
tm_polygons("HPI", title = "World - HPI") +
tm_layout(main.title = "HPI",
main.title.position = "center",
fontface = 3)
Edit: Martijn Tennekes, the author of the tmap package, has added 10 arguments to tm_layout (and therefore also tmap options) to allow control over this: a local fontface and fontfamily for the (map) title, main title, panel.label, legend.title and legend.text.
tm <- tm_shape(World) +
tm_polygons(c("HPI", "economy"), title = c("Legend 1", "Legend 2")) +
tm_layout(main.title = "Main Title",
main.title.position = "center",
title = c("Title 1", "Title 2"),
panel.labels = c("Panel 1", "Panel 2"))
# global setting
tm + tm_layout(fontface = 3)
# local setting
tm + tm_layout(main.title.fontface = 1, title.fontface = 2, panel.label.fontface = 3, legend.text.fontface = 4, legend.title.fontfamily = "serif")