omiForSubFigure {precisePlacement} | R Documentation |
Generate Values for par("omi") That Will Place a New Plot in a Sub-Region of an Existing One
Description
Generate Values for par("omi") That Will Place a New Plot in a Sub-Region of an Existing One
Usage
omiForSubFigure(
bottom,
left,
top,
right,
units = "proportion",
region = "device"
)
Arguments
bottom |
Boundary value for the bottom edge. |
left |
Boundary value for the left edge. |
top |
Boundary value for the top edge. |
right |
Boundary value for the right edge. |
units |
The units in which the boundary parameters are defined. Must be one one of "proportion" or "data". Defaults to "proportion". |
region |
The region of the plot to use for defining the boundaries. Must be one of "device", "figure", "plot", or "data". Only necessary when using units of "proportion". |
Details
The choice of accepting proportions instead of data units by default is to more easily handle empty devices, otherwise there is a risk of getting confused by the fact that par("usr") defaults to c(0, 1, 0, 1).
Author(s)
Jasper Watson
Examples
## Not run:
plot(1:10, pch = 19, col = 'black')
oldPar = par()
par(omi = omiForSubFigure(0.6, 0.25, 0.8, 0.45, region = 'device'))
par(mar = c(0,0,0,0))
plot(1:10, pch = 19, col = 'red')
par(oldPar)
par(omi = omiForSubFigure(2, 6, 5, 10, units = 'data'))
par(mar = c(0,0,0,0))
plot(1:10, pch = 19, col = 'blue')
par(oldPar)
## Illustrates how the proportions line up:
plot(1:10, pch = 19)
par(xpd = NA)
oldPar = par()
## Show where the propotions are as a reference:
abline(v = convertUnits('proportion', seq(0, 1, by = 0.1), 'data',
region = 'device', axis = 'x'), lty = 2, col = 'red')
abline(h = convertUnits('proportion', seq(0, 1, by = 0.1), 'data',
region = 'device', axis = 'y'), lty = 2, col = 'red')
## Create a new sub-plot.
par(omi = omiForSubFigure(0.2, 0.2, 0.8, 0.8, region = 'device'))
plot(1:10, pch = 19, col = 'red')
highlightFigureRegion()
par(oldPar)
## End(Not run)
[Package precisePlacement version 0.1.0 Index]