sm_north: Adds a north symbol to a ggplot map

sm_northR Documentation

Adds a north symbol to a ggplot map

Description

This function inserts a pretty north symbol in a ggplot map

Usage

sm_north(
  data = NULL,
  location = "topleft",
  scale = 0.1,
  symbol = 1,
  x.min,
  x.max,
  y.min,
  y.max,
  anchor = NULL
)

Arguments

data

The dataframe containing the spatial information for the box limits.

location

string indicating the symbol's location in the plot. Possible options: "topleft" (default), "bottomright", "bottomleft" and "topright".

scale

a variable (or vector of variables) quoted that you want to change to binary.

symbol

number between 1 and 3 to choose a symbol (1: black, 2: grey, 3: white)

x.min

if data is not defined, number with the minimum x coordinate. Useful for ggmap.

x.max

if data is not defined, number with the maximum x coordinate. Useful for ggmap.

y.min

if data is not defined, number with the minimum y coordinate. Useful for ggmap.

y.max

if data is not defined, number with the maximum y coordinate. Useful for ggmap.

anchor

named vector with coordinates to control the symbol position. For location = "topright", anchor defines the coordinates of the symbol's topright corner and so forth. The x coordinate must be named as x and the y coordinate as y.

Details

North symbols are included in the plot with the annotation_custom function, which do not works when used together with an empty call to ggplot (see last example). When it is convenient to use an empty call to ggplot, use north2 instead.

Value

The binary answers, changing "no" or "none" to 0 and "yes" to 1.

Examples

## Not run:
library(sf)
data(domestic_violence)
ggplot(domestic_violence, aes(fill = Scaled)) +
geom_sf() +
north_map(domestic_violence, location = "bottomright", symbol = 3) +
scale_fill_continuous(low = "#fff7ec", high = "#7F0000")

samesag/emu documentation built on Aug. 22, 2023, 3:19 p.m.