getFig: Return coordinates for par(fig=xxxx)

View source: R/getFig.r

getFigR Documentation

Return coordinates for par(fig=xxxx)

Description

This function can be used with the layout function for defining the positioning of multiple plots on a single plotting device. Given a matrix used in the layout function and the number indicating which a particular subplot area, it returns the min/max x- and y-coordinates for the subplot relative to the entire plottig region.

Usage

getFig(layout, n)

Arguments

layout

Matrix representing the positioning of subplots. See layout.

n

Integer, indicating which suboplot to plot (corresponds to value(s) in layout).

Value

A four-element numeric vector.

Examples

lo <- matrix(c(1, 2, 3), nrow=1)
layout(lo)
subplot1 <- getFig(lo, 1)
subplot2 <- getFig(lo, 2)
subplot3 <- getFig(lo, 3)
par(fig=subplot2, new=FALSE)
plot(1, 1, main='Subplot 2')
par(fig=subplot1, new=TRUE)
plot(1, 1, main='Subplot 1')
par(fig=subplot3, new=TRUE)
plot(1, 1, main='Subplot 3')

adamlilith/legendary documentation built on July 28, 2023, 8:13 p.m.