GetInsetLocation: Get Location for Inset in Plot

Description Usage Arguments Value Author(s) Examples

View source: R/GetInsetLocation.R

Description

Calculate x and y co-ordinates that can be used to position an inset in a plot frame at a specified keyword location.

Usage

1
GetInsetLocation(dx, dy, loc = "bottomright", inset = 0, pad = 0, padin = 0)

Arguments

dx, dy

'numeric' number. Width and height of the inset, respectively.

loc

'character' string. Single keyword used to specify the position of the inset in the main plot region: "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right", or "center" to denote inset location.

inset

'numeric' vector of length 1 or 2, value is recycled as necessary. Inset distance from the margins as a fraction of the main plot region.

pad

'numeric' vector of length 1 or 2, value is recycled as necessary. Padding distance from the margins in user coordinate units.

padin

'numeric' vector of length 1 or 2, value is recycled as necessary. Padding distance from the margins in inches.

Value

A 'numeric' vector of length 2 giving the user coordinates for the bottom-left corner of the inset.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
plot(NA, NA, xlim = c(0, 100), ylim = c(0, 1),
     xlab = "x", ylab = "y", xaxs = "i", yaxs = "i")
dx <- 20; dy <- 0.2
xy <- GetInsetLocation(dx, dy, loc = "bottomleft")
rect(xy[1], xy[2], xy[1] + dx, xy[2] + dy, border = "red")
points(xy[1], xy[2], pch = 16, xpd = TRUE)
print(xy)

xy <- GetInsetLocation(dx, dy, loc = "bottomleft", inset = 0.05)
rect(xy[1], xy[2], xy[1] + dx, xy[2] + dy, border = "pink")
points(xy[1], xy[2], pch = 16)
print(xy)

xy <- GetInsetLocation(dx, dy, loc = "topright", padin = 0.5)
rect(xy[1], xy[2], xy[1] + dx, xy[2] + dy, border = "blue")

xy <- GetInsetLocation(dx, dy, loc = "left", pad = c(5, 0))
rect(xy[1], xy[2], xy[1] + dx, xy[2] + dy, border = "green")

xy <- GetInsetLocation(dx, dy, loc = "center")
rect(xy[1], xy[2], xy[1] + dx, xy[2] + dy, border = "brown")

inlmisc documentation built on Jan. 25, 2022, 1:14 a.m.