Learn R Programming

tmap (version 1.2)

tm_compass: Map compass

Description

Creates a map compass.

Usage

tm_compass(north = 0, type = NA, fontsize = 0.8, size = NA,
  show.labels = 1, cardinal.directions = c("N", "E", "S", "W"),
  text.color = NA, color.dark = NA, color.light = NA, position = NA)

Arguments

north
north direction in degrees: 0 means up, 90 right, etc.
type
compass type, one of: "arrow", "4star", "8star", "radar", "rose". The default is controlled by tm_layout (which uses "arrow" f
fontsize
relative font size
size
size of the compass in number of text lines. The default values depend on the type: for "arrow" it is 2, for "4star" and "8star" it is 4, and for "radar" and "rose" it is 6.
show.labels
number that specifies which labels are shown: 0 means no labels, 1 (default) means only north, 2 means all four cardinal directions, and 3 means the four cardinal directions and the four intercardinal directions (e.g. north-east).
cardinal.directions
labels that are used for the cardinal directions north, east, south, and west.
text.color
color of the text. By default equal to the argument attr.color of tm_layout.
color.dark
color of the dark parts of the compass, typically (and by default) black.
color.light
color of the light parts of the compass, typically (and by default) white.
position
position of the text. Vector of two values, specifing the x and y coordinates. Either this vector contains "left", "LEFT", "center", "right", or "RIGHT" for the first value and "top", "TOP", "center", "bottom", or "BOTTOM" for the second value, or this ve

Examples

Run this code
data(NLD_muni)
qtm(NLD_muni, theme = "NLD") + tm_compass()
qtm(NLD_muni, theme = "NLD") + tm_compass(type="4star")
qtm(NLD_muni, theme = "NLD") + tm_compass(type="8star")
qtm(NLD_muni, theme = "NLD") + tm_compass(type="rose", position=c("left", "top"))
qtm(NLD_muni, theme = "NLD") + tm_compass(type="radar", position=c("left", "top"), show.labels = 3)

Run the code above in your browser using DataLab