Skip to contents

Places a resistance-surface reference panel (see plotResistance()) to the left of a network plot – for example one produced by plot() on an mpg or grain object, or any ggplot2 plot – so the two can be compared at the same size as a visual sanity check. Both panels are drawn at equal size (using cowplot::plot_grid() with align = "h" and equal coordinates) and the resistance legend is placed at the far left.

Requires the cowplot package.

Usage

plotWithResistance(x, gg, maxResistance = 12L)

Arguments

x

A resistance SpatRaster shown as the reference panel on the left (passed to plotResistance()).

gg

A plot shown on the right, e.g. the result of plot() on an mpg or grain object (typically with theme = FALSE), or any ggplot2::ggplot() object.

maxResistance

Passed to plotResistance().

Value

A two-panel plot grid produced by cowplot::plot_grid().

See also

Author

Alex M Chubaty

Examples

# \donttest{
if (requireNamespace("cowplot", quietly = TRUE)) {
  tiny <- terra::rast(
    system.file("extdata", "tiny.asc", package = "grainscape", mustWork = TRUE)
  )
  tinyCost <- terra::classify(tiny, rcl = cbind(c(1, 2, 3, 4), c(1, 5, 10, 12)))
  tinyMPG <- MPG(tinyCost, patch = tinyCost == 1)
  plotWithResistance(tinyCost, plot(tinyMPG, quick = "mpgPlot", theme = FALSE))
}

# }