mf_theme: Set a theme

View source: R/mf_theme.R

mf_themeR Documentation

Set a theme

Description

This function set a map theme. The parameters set by this function are the figure margins, background and foreground colors and some mf_title options. Use mf_theme(NULL) or mf_theme('default') to reset to default theme settings.

Usage

mf_theme(x, bg, fg, mar, tab, pos, inner, line, cex, font)

Arguments

x

name of a map theme. One of "default", "brutal", "ink", "dark", "agolalight", "candy", "darkula", "iceberg", "green", "nevermind", "jsk", "barcelona".

bg

background color

fg

foreground color

mar

margins

tab

if TRUE the title is displayed as a 'tab'

pos

title position, one of 'left', 'center', 'right'

inner

if TRUE the title is displayed inside the plot area.

line

number of lines used for the title

cex

cex of the title

font

font of the title

Details

It is also possible to set a custom theme using a list of arguments (see Examples). mf_theme() returns the current theme settings.

Value

The (invisible) list of theme parameters is returned.

Examples

mtq <- mf_get_mtq()

# Choosing a theme by name:
mf_theme("default")
mf_map(mtq)
mf_title()

# Specifying some values directly:
mf_theme(bg = "darkslategrey", fg = "lightgrey")
mf_map(mtq)
mf_title()

# Using a mix of the above:
mf_theme("brutal", fg = "lightgreen", pos = "center", font = 2, tab = FALSE)
mf_map(mtq)
mf_title()

# Specifying a list with theme values:
theme <- mf_theme("default")
theme$mar <- c(1, 1, 3, 1)
theme$line <- 2
theme$cex <- 1.5
mf_theme(theme)
mf_map(mtq)
mf_title()

# or
theme <- list(
  bg = "green",
  fg = "red",
  mar = c(2, 2, 2, 2),
  tab = TRUE,
  pos = "center",
  inner = TRUE,
  line = 2,
  cex = 1.5,
  font = 3
)
mf_theme(theme)
mf_map(mtq)
mf_title()

# Obtaining a list of parameters for the current theme:
mf_theme()

# Removing the current theme:
mf_theme(NULL)
# or
mf_theme("default")

mapsf documentation built on Nov. 21, 2023, 5:09 p.m.