subrect: subrect

View source: R/plot_extra.R

subrectR Documentation

subrect

Description

Draw shapes inside a rect

Usage

subrect(
  xleft,
  ybottom,
  xright,
  ytop,
  type = c("diagonal", "square"),
  pos = c("topleft", "topright", "bottomleft", "bottomright"),
  ...
)

Arguments

xleft, ybottom, xright, ytop

coordinates of the main rect

type, pos

the type (diagonal or square) and position of the shape inside the rect

...

additional arguments passed to rect

Examples

pos <- eval(formals(subrect)$pos)
par(mfrow = n2mfrow(length(pos)))

for (p in pos) {
  plot(0, 0, main = p, type = 'n', xlab = '', ylab = '')
  rect(-0.5, -0.5, 0.5, 0.5)
  subrect(-0.5, -0.5, 0.5, 0.5, type = 'diag', pos = p, col = 'red')
}

for (p in pos) {
  plot(0, 0, main = p, type = 'n', xlab = '', ylab = '')
  rect(-0.5, -0.5, 0.5, 0.5)
  subrect(-0.5, -0.5, 0.5, 0.5, type = 'square', pos = p, col = 'red')
}


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.