Package 'kwb.rect'

Title: R Package for Plotting Rectangles
Description: This package provides functions to define and plot rectangles, e.g. to plot rectangles side-by-side or on top of each other.
Authors: Hauke Sonnenberg [aut, cre] , Kompetenzzentrum Wasser Berlin gGmbH (KWB) [cph]
Maintainer: Hauke Sonnenberg <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2024-11-20 10:37:40 UTC
Source: https://github.com/KWB-R/kwb.rect

Help Index


Combine Rectangles

Description

Combine Rectangles

Usage

## S3 method for class 'rects'
c(...)

Arguments

...

one or more objects of class "rects"


Generic Function to Move Objects

Description

Generic Function to Move Objects

Usage

move(rects, ...)

Arguments

rects

objects to be moved

...

arguments passed to class methods


Move Rectangles

Description

Move Rectangles

Usage

## S3 method for class 'rects'
move(
  rects,
  dx = 0,
  dy = 0,
  top = NULL,
  bottom = NULL,
  left = NULL,
  right = NULL,
  each = FALSE,
  ...
)

Arguments

rects

A "rects" object

dx

delta x

dy

delta y

top

top position

bottom

bottom position

left

left position

right

right position

each

logical indicating whether to move each rectangle or the group of rectangles

...

additional arguments (currently not used)


Create a "rects" object

Description

Create a "rects" object

Usage

new_rects(
  w = 1,
  h = 1,
  llx = 0,
  lly = 0,
  lbl_text = NULL,
  lbl_align = "centre",
  density = -1,
  angle = 45,
  col = NA,
  border = graphics::par("fg"),
  lty = graphics::par("lty"),
  lwd = graphics::par("lwd"),
  n = NULL
)

Arguments

w

width(s) of rectangle(s)

h

height(s) of rectangle(s)

llx

x position(s) of lower left corner(s) of rectangle(s)

lly

y position(s) of lower left corner(s) of rectangle(s)

lbl_text

text label(s)

lbl_align

label alignment(s), default: "centre"

density

density of shade lines. Default: -1

angle

angle of shade lines. Default: 45

col

fill colour(s) of rectangles

border

border colour(s) of rectangles

lty

line type(s) of rectangles

lwd

line width(s) of rectangles

n

number of rectangles. All other arguments are recycled to vectors of this length.


Plot Rectangles

Description

Plot Rectangles

Usage

## S3 method for class 'rects'
plot(x, add = !is.null(grDevices::dev.list()), cex = 1, y = NULL, ...)

Arguments

x

object of class "rects"

add

logical indicating whether to add rectangles to an existing plot or to start a new plot

cex

character expansion factor

y

not used. Just there to comply with the generic plot() interface.

...

additional arguments (currently not used)


Separate Rectangles

Description

Separate Rectangles

Usage

## S3 method for class 'rects'
separate(x, dx = 0, dy = 0, ...)

Arguments

x

"rects" object

dx

space in horizontal direction to be put in between the rectangles

dy

space in vertical direction to be put in between the rectangles

...

further arguments (currently not used)


Stack Rectangles

Description

Stack Rectangles

Usage

stack(rects, ...)

Arguments

rects

a "rects" object

...

further arguments passed to stack.rects


Stack Rectangles Vertically or Horizontally

Description

Stack Rectangles Vertically or Horizontally

Usage

## S3 method for class 'rects'
stack(rects, horizontal = FALSE, delta = 0, reverse = FALSE, ...)

Arguments

rects

a "rects" object as returned by new_rects

horizontal

whether to stack the rectangles horizontally or not. The default is FALSE, i.e. rectangles are stacked vertically.

delta

space between rectangles, default: 0

reverse

whether or not to reverse the stack order. The default is FALSE.

...

not used

Examples

rects <- new_rects(w = 1:3)
stacked_vertically <- stack(rects)
stacked_horizontally <- stack(rects, horizontal = TRUE)
plot(stacked_vertically, add = FALSE)
plot(stacked_horizontally, add = FALSE)
stacked_vertically_spaced <- stack(rects, delta = 0.1)
stacked_horizontally_spaced <- stack(rects, horizontal = TRUE, delta = 0.1)
plot(stacked_vertically_spaced, add = FALSE)
plot(stacked_horizontally_spaced, add = FALSE)