plot_map: Map one or more columns of gridded or polygon data

View source: R/plot.R

plot_mapR Documentation

Map one or more columns of gridded or polygon data

Description

An sf object with polygons gives a choropleth. A data frame with latitude and longitude gives one square for each grid point.

Usage

plot_map(
  data,
  column,
  boundaries = NULL,
  facet = NULL,
  log = FALSE,
  months = FALSE,
  labels = NULL,
  cmap = "viridis",
  center = NULL,
  title = NULL,
  legend_title = NULL
)

Arguments

data

sf object with polygons, or data frame with latitude and longitude

column

Column to colour by. A vector gives one panel per column, with one shared colour scale.

boundaries

Optional sf polygons to draw as outlines on top

facet

Optional column. One panel per value (for example a period).

log

Use a log colour scale (values must be positive)

months

The values are months (1-12). Use 12 discrete colours and month names in the legend, for example for peak_month.

labels

Optional column to write at each polygon centre

cmap

Viridis option name ("viridis", "plasma", ...) or a diverging palette name from ggplot2::scale_fill_distiller()

center

Centre a diverging palette on this value, with limits the same distance on each side (for example 0 for a bias). Use it with a diverging cmap such as "RdBu".

title

Plot title

legend_title

Legend title. The default is the column name.

Value

ggplot object

Examples


grid <- expand.grid(latitude = seq(10, 12, 0.5), longitude = seq(70, 72, 0.5))
grid$t2m <- grid$latitude + grid$longitude
plot_map(grid, "t2m")


varunayan documentation built on Oct. 30, 2026, 1:07 a.m.