ggartprint_example_map: Make a print of a map in R

View source: R/ggartprint_example_map.R

ggartprint_example_mapR Documentation

Make a print of a map in R

Description

This example uses Open Street Map data to make a print of a map. It's based on a tutorial by Joshua McCrain.

Usage

ggartprint_example_map(
  title,
  subtitle,
  coordinates = NULL,
  colors = NULL,
  text_rel_sizes = NULL
)

Arguments

title

The larger top line of text above the plot, if coordinates not specified also used to find the map location

subtitle

The smaller lower line of text above the plot, if coordinates not specified also used to find the map location

coordinates

(optional) exactly the location for the map. Needs to be a matrix with row names c("x","y") and column names c("min","max"). Ex: matrix(c(-122.460,47.481, -122.224,47.734), nrow=2, dimnames = list(c("x","y"),c("min","max")))

colors

(optional) a named vector of colors to use for the plot. Defaults to c(back = "#FEFDF7", grid = "#FCF3DB", text = "#474973", axis_text = "#E1C886", roads = "#474973", trains = "#474973")

text_rel_sizes

(optional) the relative sizes of the text to use. Defaults to c(title = 3.5, subtitle = 2.5, axis = 0.4)

Details

The location of the map is either derived from the header string ("title, subtitle"), or can be specified precisely using the coordinates option.

The sizing was tested using an 11"x14" print with portrait orientation–other sizes and shapes will require adjusting the text size using the text_rel_sizes parameter.

It's recommended you pass ggartprint the parameter background="#FEFDF7" to avoid having white margins around the print.

Value

a ggplot2 plot to pass to ggartprint

Examples

library(ggirl)
contact_email <- "fakeemailforreal@gmail.com"
delivery_address <- address(name = "Fake Personname", address_line_1 = "250 North Ave",
                          city = "Boston", state = "MA",
                          postal_code = "22222", country = "US")
plot <- ggartprint_example_map("Seattle", "Washington")
background <- "#FEFDF7" # use the background option only when your background isn't white
ggartprint(plot, size = "11x14", orientation = "portrait",
                                contact_email = contact_email,
                                address = delivery_address,
                                background = background)

jnolis/ggirl documentation built on July 1, 2023, 4:51 p.m.