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 |
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 |
basemap |
if |
colorRampRange |
numeric vector of min and max value for scaling the
color ramp. Automatically inferred if set to |
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
|
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 |
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 |
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')