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 |
Combine Rectangles
## S3 method for class 'rects' c(...)
## S3 method for class 'rects' c(...)
... |
one or more objects of class "rects" |
Generic Function to Move Objects
move(rects, ...)
move(rects, ...)
rects |
objects to be moved |
... |
arguments passed to class methods |
Move Rectangles
## S3 method for class 'rects' move( rects, dx = 0, dy = 0, top = NULL, bottom = NULL, left = NULL, right = NULL, each = FALSE, ... )
## S3 method for class 'rects' move( rects, dx = 0, dy = 0, top = NULL, bottom = NULL, left = NULL, right = NULL, each = FALSE, ... )
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
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 )
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 )
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
## S3 method for class 'rects' plot(x, add = !is.null(grDevices::dev.list()), cex = 1, y = NULL, ...)
## S3 method for class 'rects' plot(x, add = !is.null(grDevices::dev.list()), cex = 1, y = NULL, ...)
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
## S3 method for class 'rects' separate(x, dx = 0, dy = 0, ...)
## S3 method for class 'rects' separate(x, dx = 0, dy = 0, ...)
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
stack(rects, ...)
stack(rects, ...)
rects |
a "rects" object |
... |
further arguments passed to |
Stack Rectangles Vertically or Horizontally
## S3 method for class 'rects' stack(rects, horizontal = FALSE, delta = 0, reverse = FALSE, ...)
## S3 method for class 'rects' stack(rects, horizontal = FALSE, delta = 0, reverse = FALSE, ...)
rects |
a "rects" object as returned by |
horizontal |
whether to stack the rectangles horizontally or not. The
default is |
delta |
space between rectangles, default: 0 |
reverse |
whether or not to reverse the stack order. The default is
|
... |
not used |
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)
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)