Skip to contents

mf_theme() sets a map theme. A theme is a set of graphical parameters that are applied to maps created with mapsf. These parameters are the figure margins, background and foreground colors and mf_title() options. mapsf offers some builtin themes. It’s possible to modify an existing theme or to start a theme from scratch. Themes are persistent across maps produced by mapsf (e.g. they survive a dev.off() call).

Builtin themes

Here are the builtin themes. We have added a grey background color to make the margins more visible.

The following table displays the parameters of these themes.

bg fg mar tab pos inner line cex font
default #f7f7f7 #333333 c(0.5, 0.5, 1.7, 0.5) TRUE left FALSE 1.2 1 1
ink #FFDEAD #0000FF c(0, 0, 1.2, 0) FALSE left FALSE 1.2 0.9 2
dark #2E3947 #7E848C c(0.5, 0.5, 2, 0.5) FALSE left FALSE 1.5 1 1
agolalight #EDF4F5 #82888A c(0, 0, 2, 0) FALSE left FALSE 2 1.5 3
candy #FDFCFE #6B1767 c(0, 0, 2, 0) FALSE center FALSE 2 1.5 2
darkula #232525 #A9B7C6 c(0.5, 0.5, 0.5, 0.5) TRUE right TRUE 1.5 1 4
iceberg #0B0E0E #BDD6DB c(0.5, 0.5, 0.5, 0.5) TRUE right TRUE 1.5 1 4
green #1B1D16 #D7FF68 c(0.5, 0.5, 2, 0.5) FALSE center FALSE 1.5 1 2
nevermind #4DB8DA #121725 c(2, 2, 3.5, 2) FALSE center FALSE 1.5 1.4 1
jsk #ffdc11 #0c973c c(0, 0, 1.5, 0) FALSE left FALSE 1.5 1 2
barcelona #160808 #d73e23 c(0, 0, 1.2, 0) TRUE left FALSE 1.2 1 2

How to modify an existing theme

It is possible to modify an existing theme. In this example we use the “default” theme and modify some title parameters.

library(mapsf)
mtq <- mf_get_mtq()
mf_theme("default", tab = FALSE, font = 4)
mf_map(mtq)
mf_title('Mofified "default" theme')

How to create a new theme

It is possible to create a new theme.

mf_theme(
  bg = "lightblue", fg = "tomato1", mar = c(0, 2, 0, 2),
  tab = TRUE, inner = TRUE, line = 1.3, pos = "center",
  cex = 1.1, font = 3
)
mf_map(mtq)
mf_title("New theme")

It is also possible to assign a theme to a variable.

blue_theme <- mf_theme("dark", bg = "lightblue")
green_theme <- mf_theme("default", bg = "lightgreen")
mf_theme(blue_theme)
mf_map(mtq)
mf_title("Blue Theme")

mf_theme(green_theme)
mf_map(mtq)
mf_title("Green Theme")