Skip to contents

Writes ggplot maps from plot_sites(), plot_geo(), plot_sdm(), plot_topo() (or any ggplot / patchwork object) to disk. Format is taken from the file extension. geo_save() is the geospatial-oriented name; tidydiversity::plot_save() is the general journal-size helper (also used outside maps).

Usage

geo_save(
  plot,
  path,
  width = 180,
  height = 140,
  units = c("mm", "cm", "in", "px"),
  dpi = 300,
  bg = "white",
  ...
)

Arguments

plot

A ggplot or patchwork map object.

path

Output path. The extension selects the device (.png, .pdf, .svg, .tiff/.tif, .jpg/.jpeg).

width, height

Size in units. For geo_save(), defaults are 180 mm wide and 140 mm tall (a comfortable single map panel).

units

"mm", "cm", "in", or "px".

dpi

Resolution for raster formats (default 300 for print).

bg

Background colour (default "white").

...

Passed to ggplot2::ggsave() (device-specific extras such as compression, family, or useDingbats).

Value

path, invisibly.

Examples

p <- plot_sites(
  geo_example_sites("wilhelm"), lon, lat,
  colour = elevation_band, basemap = "none",
  scale_bar = FALSE, north_arrow = FALSE
)
f <- tempfile(fileext = ".png")
geo_save(p, f, width = 80, height = 60, units = "mm")