View source: R/machuruku_code.R
machu.plotmap | R Documentation |
Plot one or more niche models using model output from machu.3.anc.niche(). User can specify color ramps inspired by the viridis package and plot maps in various configurations.
machu.plotmap(
model,
col = 1,
axes = T,
title = T,
title.cex = 1,
to.scale = F,
plot = "separately",
plot.asp = 16/9
)
model |
Output from machu.3.anc.niche(), a list of lists of SpatRasters, generally one per taxon per timeslice. Subsettable, though this may interfere with the format of titles. |
col |
Desired color ramp, usually a numeric value from 1 to 6. 1 = base; 2 = plasma; 3 = viridis; 4 = l17 pure white; 5 = r3 pure blue; 6 = black and white. Ramps can also be specified with strings, e.g. "viridis" or "v". Custom color ramps (character vectors with length > 1) can also be supplied, for example by the colorRampPalette function. Default = 1 ("base"). |
axes |
Whether to display axes (lat/long). Default = T. |
title |
Whether to display titles. These are supposed to take the format "timeslice, taxon", but certain input formats from machu.3.anc.niche, or subsetting the input, may interfere with this. Default = T. |
title.cex |
Specify size of titles. Default = 1. |
to.scale |
Whether to color each raster according to the same scale (i.e., the min and max value among all rasters) so that they can be directly compared. Default = F. |
plot |
How to arrange plots of multiple climate variables. When "separate", plot each in its own window. When "together", plot all in the same window, using n2mfrow to calculate the best arrangement given a specified aspect ratio ('plot.asp'). Default = "separately". |
plot.asp |
Aspect ratio used to calculate the best arrangement of plots when plot="together". Default = 16/9. |
Titles may not display properly (timeslice, taxon) depending on the input format from machu.3.anc.niche and the amount of subsetting of the input.
Implementing scale bars was more trouble than I wanted to deal with so currently they are not supported with this function. Using the plot() function will automatically generate one for your raster though.
When to.scale=T, the function calculates the minimum and maximum suitability value among all the input rasters, and scales the color for each one using this range. This enables the rasters to be directly compared; as such, when to.scale=F, comparing the rasters can be misleading.
Plots of niche models in various configurations.
# plot all models, separately, with default color ramp, axes, and titles
machu.plotmap(model)
# together
machu.plotmap(model, plot="t")
# no axes or titles
machu.plotmap(model, plot="t", axes=F, title=F)
# plot all rasters on the same color scale
machu.plotmap(model, plot="t", axes=F, title=F, to.scale=T)
# plot only the first raster, using the "viridis" color ramp
machu.plotmap(model[[1]][[1]], col=3)
# plot only rasters from the first timeslice/scenario, using a custom "Mardi Gras" color ramp
mardi.gras <- colorRampPalette(c("purple", "forestgreen", "gold"))(256)
machu.plotmap(model[[1]], col=mardi.gras, plot="t")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.