Plot historical dispersal contribution from source areas
plot_dispersal_from.RdThis 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
sfobject 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_fromshould be used (plural). IfNULL(default), all columns are used.- area_col
Integer indicating a single column of
dispersal_fromto be plotted (singular). This argument is only used whenfacet = FALSEand must be one of the values provided inarea_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 inarea_colsare plotted usingfacet_wrap(). IfFALSE, a single area defined byarea_colis plotted.
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.