plot.epmGrid {epm}R Documentation

Plot epmGrid

Description

Plot a epmGrid object. This function uses the tmap package for plotting by default.

Usage

## S3 method for class 'epmGrid'
plot(
  x,
  log = FALSE,
  legend = TRUE,
  col,
  basemap = "worldmap",
  colorRampRange = NULL,
  minTaxCount = "auto",
  zoom = TRUE,
  ignoredColor = gray(0.9),
  lwd,
  borderCol = "black",
  alpha = 1,
  includeFrame = FALSE,
  use_tmap = TRUE,
  fastPoints = FALSE,
  title = "",
  add = FALSE,
  ...
)

Arguments

x

object of class epmGrid

log

boolean; should the cell values be logged?

legend

boolean; should legend be included?

col

either a vector of color names that will be interpolated, or a color ramp function that takes an integer (see for example colorRampPalette).

basemap

if 'none', then only the grid is plotted. If 'worldmap', then vector map is plotted. If 'interactive', then the plot is sent to the web browser.

colorRampRange

numeric vector of min and max value for scaling the color ramp. Automatically inferred if set to NULL. This is relevant if multiple plots are desired on the same scale. See getMultiMapRamp.

minTaxCount

an integer, or 'auto'. Should cells containing certain numbers of taxa be grayed out? For example, should single-taxon cells be ignored because the metric only makes sense for multi-taxon cells? This is predetermined for all metrics in gridMetrics if minTaxCount = 'auto'.

zoom

Should plot zoom in on cells with data. Default is TRUE.

ignoredColor

color for ignored cells. See details.

lwd

grid cell border width

borderCol

color for grid cell borders

alpha

opacity of all colors and borders, ranging from 0 (fully transparent) to 1 (fully opaque)

includeFrame

boolean; include frame around plot?

use_tmap

boolean; if FALSE, plotting will be done via sf instead of tmap package

fastPoints

Intended for debugging purposes. For hex grids and use_tmap = F, plot points instead of polygons. Helpful for sorting out plotting details without waiting for slow polygon plotting.

title

text to add to the plot

add

logical, add to existing plot?

...

additional arguments that can be passed to sf::plot or terra::plot if use_tmap = FALSE

Details

If x is a metric as generated with gridMetrics that returns 0 for single-species cells, then those cells (that have a value of 0) will be plotted in gray (or any color as specified with ignoredColor) if minTaxCount = 'auto'. You can specify other values as well. For instance, if you use the function customGridMetric to calculate phylogenetic signal, which is a metric that only makes sense for cells with 3 or more taxa, then you could then specify minTaxCount = 3. Setting minTaxCount = 1 shows all cells with data.

If the tmap package is not installed, then this function will default to plotting with sf::plot.

If you would like more control over the legend, then plot with tmap = FALSE and legend = FALSE, and then call the function addLegend.

Value

Nothing is returned if plotting with tmap (the default). If plotting with use_tmap = FALSE, and if the plot is directed to a variable, then this variable will contain relevant information to be passed on to the function addLegend:

Author(s)

Pascal Title

Examples

plot(tamiasEPM, use_tmap = FALSE)

plot(tamiasEPM, legend = FALSE, use_tmap = FALSE, col = viridisLite::inferno)
addLegend(tamiasEPM, location = 'top', ramp = viridisLite::inferno)

 
# Example for how to plot multiple epmGrids on the same color scale
# for illustration purposes, we will compare weighted endemism to
# phylogenetic weighted endemism
library(tmap)

tamiasEPM <- addPhylo(tamiasEPM, tamiasTree)
epm1 <- gridMetrics(tamiasEPM, metric='weightedEndemism')
epm2 <- gridMetrics(tamiasEPM, metric='phyloWeightedEndemism')
# get global min and max values
minmax <- getMultiMapRamp(epm1, epm2)

map1 <- plot(epm1, colorRampRange = log(minmax), log = TRUE, legend = FALSE)
map2 <- plot(epm2, colorRampRange = log(minmax), log = TRUE, legend = FALSE)
# tmap_arrange(map1, map2)

# view your plot in the web-browser as a dynamic plot.
plot(tamiasEPM, basemap = 'interactive')


# Adding a custom legend, and passing along arguments via params
xx <- plot(tamiasEPM, use_tmap = FALSE, legend = FALSE, 
col = viridisLite::magma)
addLegend(tamiasEPM, params = xx, location = 'bottom')


[Package epm version 1.1.2 Index]