tmap_style: Set or get the default tmap style

Description Usage Arguments Details Value See Also Examples

View source: R/tmap_style.R

Description

Set or get the default tmap style. Without arguments, the current style is returned. Also the available styles are displayed. When a style is set, the corresponding tmap options (see tmap_options) will be set accordingly. The default style (i.e. when loading the package) is "white".

Usage

1
tmap_style(style)

Arguments

style

name of the style. When omitted, tmap_style returns the current style and also shows all available styles. When the style is specified, tmap_style sets the style accordingly. Note that in that case, all tmap options (see tmap_options) will be reset according to the style definition. See tm_layout for predefined styles, and tmap_style_catalogue for creating a catalogue.

Details

Note that tm_style is used within a plot call (so it only affects that plot), whereas tmap_style sets the style globally.

After loading a style, the options that defined this style (i.e. the difference with the default "white" style) can be obtained by tmap_options_diff.

The documentation of tmap_options (details and the examples) shows how a new style is created.

Value

the style before changing

See Also

tmap_options for tmap options, and tmap_style_catalogue to create a style catalogue of all available styles.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(World)

current.style <- tmap_style("classic")
qtm(World, fill="life_exp", fill.title="Life expectancy")

tmap_style("cobalt")
qtm(World, fill="life_exp", fill.title="Life expectancy")

# restore current style
tmap_style(current.style)

Example output

tmap style set to "classic"
other available styles are: "white", "gray", "natural", "cobalt", "col_blind", "albatross", "beaver", "bw", "watercolor" 
tmap style set to "cobalt"
other available styles are: "white", "gray", "natural", "col_blind", "albatross", "beaver", "bw", "classic", "watercolor" 
tmap style set to "white"
other available styles are: "gray", "natural", "cobalt", "col_blind", "albatross", "beaver", "bw", "classic", "watercolor" 

tmap documentation built on June 16, 2021, 9:10 a.m.