tmap_mode: Get or set tmap mode

View source: R/tmap_mode.R

tmap_modeR Documentation

Get or set tmap mode

Description

  • tmap_mode() gets (no argument) or sets the current mode.

  • ttm() toggles between the two most recent modes.

  • ttmp() same as ttm(), then calls tmap_last().

  • rtm() rotates through all modes in the pool.

  • rtmp() same as rtm(), then calls tmap_last().

  • tmap_mode_pool() restricts which modes are cycled by ttm() and rtm(). Call without arguments to inspect the current pool, or pass NULL to reset.

It is recommended to use tmap_mode() in scripts and ttm()/ttmp() in the console.

Usage

tmap_mode(mode = NULL, silent = FALSE)

ttm()

rtm()

tmap_mode_pool(modes = NULL, silent = FALSE)

ttmp()

rtmp()

Arguments

mode

A string specifying the mode. See tmap_options() for available modes.

silent

Should the mode be switched silently? Default FALSE.

modes

Character vector of mode names (minimum 2), or NULL to reset.

Details

The default modes are "plot" (static, graphics device) and "view" (interactive, browser or RStudio Viewer). Additional modes such as "maplibre" and "mapbox" become available when tmap.mapgl is loaded.

Value

  • tmap_mode() returns the current mode invisibly when called without argument, otherwise the previous mode.

  • ttm(), rtm() return the previous mode invisibly.

  • tmap_mode_pool() returns the previous pool invisibly.

References

Tennekes, M., 2018, tmap: Thematic Maps in R, Journal of Statistical Software, 84(6), 1-39, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v084.i06")}

See Also

  • .doc_see_also_modes()

  • tmap_last() to show the last map

  • tm_view() for viewing options

  • tmap_leaflet() for obtaining a leaflet widget

  • tmap_options() for tmap options

Examples

current.mode = tmap_mode()

tmap_mode("plot")

tm_shape(World) + tm_polygons("HPI")

tmap_mode("view")

tm_shape(World) + tm_polygons("HPI")

ttm()

tm_shape(World) + tm_polygons("HPI")

tmap_mode(current.mode)

tmap documentation built on June 26, 2026, 5:08 p.m.