Skip to contents

This function plots spatial patterns of historical dispersal contribution from one or multiple source areas. The user can visualize a single area or multiple areas simultaneously using facet_wrap().

Usage

plot_dispersal_from(
  dispersal_from,
  coords,
  shapefile,
  area_cols = NULL,
  area_col = NULL,
  color_palette = "SunsetDark",
  facet = FALSE
)

Arguments

dispersal_from

A data.frame generated by calc_dispersal_from where each column represents dispersal contribution from a source area, and each row corresponds to a spatial cell

coords

A rectangular object (it can be a matrix, data.frame or tibble) containing two columns, one with longitude and another with latitude coordinates in this order.

shapefile

An sf object containing the geographic boundaries to be overlaid on the raster map (e.g., continents, biogeographic regions, or study area limits).

area_cols

Integer vector indicating which columns of dispersal_from should be used (plural). If NULL (default), all columns are used.

area_col

Integer indicating a single column of dispersal_from to be plotted (singular). This argument is only used when facet = FALSE and must be one of the values provided in area_cols.

color_palette

character string specifying the color palette to be used for quantitative variables in rcartocolor::scale_fill_carto_c. Ignored for "DR_prop", which uses a fixed palette and scale. Default is "SunsetDark"

facet

Logical. If TRUE, all areas defined in area_cols are plotted using facet_wrap(). If FALSE, a single area defined by area_col is plotted.

Value

A ggplot object.

Details

When multiple areas are plotted, the order of the facets follows the order of the columns provided in area_cols, not alphabetical order.

The function assumes that dispersal_from and coords have the same number of rows and are ordered consistently.

All area selections are performed using numeric column indices, ensuring an unambiguous mapping to the original columns of dispersal_from.

Author

Maria Gabriela Junqueira and Gabriel Nakamura

Examples