Skip to contents

A theme for map plates in the manner of the Urban Atlas: off-white paper, a thin neatline around the panel, no axes, and the legend as a single strip of bold capitals in the ink of the mapped variable, above the panel on the left. Titles and captions are set in the tan of the base map.

Usage

theme_urban(
  base_size = 11,
  fonts = "manifold",
  ink = "density",
  palette = NULL,
  axes = FALSE,
  caps_family = NULL,
  text_family = NULL
)

Arguments

base_size

Base font size in points. Legend text, titles, and captions are all set at this size, as on the original plates.

fonts

The font set, passed to urban_fonts(): one of "manifold", "broadway", "subway", or "narroway".

ink

The ink of the legend text: a role from urban_inks(), such as "density" or "income", or any colour.

palette

The ink palette, passed to urban_inks().

axes

If TRUE, draw axis labels and titles in the base-map tan, for charts. The default, FALSE, suits maps.

caps_family, text_family

Font families that override those chosen by fonts.

Value

A ggplot2 theme.

Details

The theme also sets the default ink and paper of ordinary geoms through ggplot2::element_geom(), so that line work such as geom_sf() is drawn in the base-map tan unless a colour is given.

Graphics devices

The fonts are system fonts. Draw plots that use this theme on a device that can find system fonts, such as those of the ragg or svglite packages, or cairo_pdf() for PDF output. The base pdf() device cannot use these fonts.

Examples

# The fonts need a graphics device that can find system fonts, such as ragg.
library(ggplot2)

cells <- expand.grid(x = 1:8, y = 1:6)
cells$people <- 4000 * exp(-((cells$x - 3)^2 + (cells$y - 3)^2) / 6)

ggplot(cells, aes(x, y, level = people)) +
  geom_urban_disc() +
  scale_level_binned(
    name = "RESIDENTIAL POPULATION DENSITY",
    breaks = c(50, 200, 500, 1200, 3600)
  ) +
  coord_equal() +
  labs(caption = "NEW YORK WEST") +
  theme_urban()
#> Warning: Can't find the font family "Manifold Extended CF".
#> ℹ Using the default sans-serif instead.
#> This warning is displayed once per session.
#> Warning: Can't find the font family "Manifold CF".
#> ℹ Using the default sans-serif instead.
#> This warning is displayed once per session.