north: North symbol

Description Usage Arguments Details Examples

View source: R/north.R

Description

Adds a north symbol to maps created with ggplot or ggmap.

Usage

1
2
north(data = NULL, location = "topright", scale = 0.1, symbol = 1,
  x.min, x.max, y.min, y.max, anchor = NULL)

Arguments

data

the same data.frame passed to ggplot to plot the map.

location

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

scale

number between 0 and 1 to indicate the symbol size as a proportion of the map size (bounding box).

symbol

number between 1 and 18 to choose a symbol (see northSymbols).

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.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
library(sf)
data(domestic_violence)
ggplot(domestic_violence, aes(fill = Scaled)) +
    geom_sf() +
    north(domestic_violence, location = "bottomright", symbol = 15) +
    scale_fill_continuous(low = "#fff7ec", high = "#7F0000")

## End(Not run)

Example output

Loading required package: ggplot2
Loading required package: grid
Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1

ggsn documentation built on May 1, 2019, 8:21 p.m.