add_boundary_box: Add a bounding box around observations at specified...

View source: R/add_boundary_box.R

add_boundary_boxR Documentation

Add a bounding box around observations at specified coordinates

Description

This function adds a bounding box around observations on a plot at specified coordinates.

Usage

add_boundary_box(x, ...)

Arguments

x

A vector of length four which specifies (1) the minimum x value of the box; (2) the maximum x value of the box; (3) the minimum y value of the box; and (4) the maximum y value of the box.

...

Other arguments passed to rect.

Value

The function adds a rectangular box around observations at specified coordinates.

Author(s)

Edward Lavender

Source

This is a simple wrapper for rect.

Examples

# Simulate some observations
x <- runif(100, 0, 1)
y <- runif(100, 10, 20)

# Visualise observations and a boundary box around the range of the values
# ... and the 0.05 0.95 quantiles:
plot(x, y)
add_boundary_box(c(range(x), range(y)), border = "red")
add_boundary_box(c(stats::quantile(x, prob = c(0.05, 0.95)),
                   stats::quantile(y, prob = c(0.05, 0.95))),
                   border = "red", lty = 3)

# Visualise an example raster and add boundary box of extent
raster::plot(dat_gebco)
add_boundary_box(raster::extent(dat_gebco), border = "royalblue", lwd = 2)


edwardlavender/prettyGraphics documentation built on Jan. 19, 2025, 2:47 p.m.