sm_north | R Documentation |
This function inserts a pretty north symbol in a ggplot map
sm_north(
data = NULL,
location = "topleft",
scale = 0.1,
symbol = 1,
x.min,
x.max,
y.min,
y.max,
anchor = NULL
)
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. |
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.
The binary answers, changing "no" or "none" to 0 and "yes" to 1.
## 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.