plot.habitat: Plot Options For a 'habitat' Object

View source: R/class_plot.R

plot.habitatR Documentation

Plot Options For a 'habitat' Object

Description

S3 method for class 'habitat'. plot.habitat creates plots for objects of class habitat, using the R base plotting framework. The exact plot generated depends on whether the input data comes from sar_habitat or sar_countryside.

Usage

## S3 method for class 'habitat'
plot(
  x,
  IC = "AICc",
  type = 1,
  powFit = TRUE,
  lcol = NULL,
  pLeg = TRUE,
  legPos = "bottomright",
  legInset = 0,
  ...
)

Arguments

x

An object of class 'habitat'.

IC

The information criterion weights to present (must be one of 'AIC', 'BIC' or 'AICc'), if plotting a sar_habitat object.

type

Whether a Type 1 or Type 2 plot should be generated, if plotting a sar_countryside object (see details).

powFit

For Type 1 plots, should the predicted total richness values of the power (or logarithmic) model be included as red points (logical argument).

lcol

For Type 2 plots: the colours of the fitted lines, for each component model. Should be a vector, the length (and order) of which should match the number of species groups in x. If not included, randomly selected colours are used.

pLeg

For Type 2 plots: should a legend be included (logical argument), showing the line colours and corresponding species groups.

legPos

For Type 2 plots: the location of the legend. Can either be a position (e.g., "bottomright"), or the x and y co-ordinates to be used to position the legend (e.g., c(0,5)).

legInset

For Type 2 plots: the inset argument in legend. Enables the legend to be plotted outside the plotting window (it still needs the user to manually change their graphical margin parameters).

...

Further graphical parameters may be supplied as arguments.

Details

The exact plot that is generated depends on the input data. If x is the fit object from sar_habitat, a simple barplot of information criterion (IC) weights for the different model fits is produced. The particular IC metric to use is chosen using the IC argument.

If x is the fit object from sar_countryside, two plot types can be produced (selected using the type argument). A Type 1 plot plots the predicted total richness values (from both countryside and Arrhenius power (or logarithmic) SAR models) against the observed total richness values, with a regression line (intercept = 0, slope = 1) included to aid interpretation.

A Type 2 plot uses countryside_extrap internally to generate separate fitted SAR curves for each of the modelled species groups, using a set of hypothetical sites (with area values ranging from the minimum to the maximum observed habitat area values across all sites) in which the proportion of the focal habitat relative to a specific species group (e.g., forest for forest species) is always 100 percent. For ubiquitous species, the mean number of species across each of the component models is calculated and used for plotting. See Matthews et al. (2025) for further details.

Note that the logarithmic SAR model doesn't work with zero area values, so if any habitat area values are zero, the minimum area value of the 'hypothetical' sites used to generate the fitted curves in a Type 2 plot is set to 0.01 if this model is used.

References

Matthews et al. (2025) An R package for fitting multi-habitat species–area relationship models. In prep.

Examples

#Run the sar_habitat function and generate a barplot of the AICc
#values
data(habitat)

s <- sar_habitat(data = habitat, modType = "power_log",
con = NULL, logT = log)

plot(s, IC = "AICc", col = "darkred")

## Not run: 
#Run the sar_countryside function and generate a Type 1 plot,
#including the predicted values of the standard power model
data(countryside)

s3 <- sar_countryside(data = countryside, modType = "power",
gridStart = "partial", ubiSp = TRUE, habNam = c("AG", "SH",
"F"), spNam = c("AG_Sp", "SH_Sp", "F_Sp", "UB_Sp"))

plot(s3, type = 1, powFit = TRUE)

#Generate a Type 2 plot providing set line colours, including
#a legend and positioning it outside the main plotting window,
#and modifying other aspects of the plot using the standard
#base R plotting commands.
#Note this will change the graphical margins of your plotting
#window.
par(mar=c(5.1, 4.1, 4.1, 7.5), xpd=TRUE)

plot(s3, type = 2, lcol = c("black", "aquamarine4",
"#CC661AB3" , "darkblue"), pLeg = TRUE,  legPos ="topright",
legInset = c(-0.2,0.3), lwd = 1.5)


## End(Not run)

txm676/mmSAR2 documentation built on Nov. 21, 2024, 5:03 a.m.