Learn R Programming

itsadug (version 1.0.1)

getFigCoords: Get the figure region as coordinates of the current plot region.

Description

Get the figure region as coordinates of the current plot region.

Usage

getFigCoords(input = "f")

Arguments

input
Text string: 'f' (figure, default), 'p' (plot region), 'hf' (half way figure region), or 'hp' (half way plot region)

Value

  • A vector of the form c(x1, x2, y1, y2) giving the boundaries of the figure region as coordinates of the current plot region.

See Also

Other Utility functions for plotting: addInterval; alphaPalette; alpha; color_contour; dotplot_error; emptyPlot; errorBars; fadeRug; fill_area; find_difference; getCoords; gradientLegend; horiz_error; plot_error

Examples

Run this code
# setup plot region:
emptyPlot(1,1, bty='o')
fc <- getFigCoords()
pc <- getFigCoords('p')
arrows(x0=pc[c(1,2,1,2)], x1=fc[c(1,2,1,2)],
    y0=pc[c(3,3,4,4)], y1=fc[c(3,3,4,4)], xpd=TRUE)

# Same plot with different axis:
emptyPlot(c(250,500),c(331, 336), bty='o')
fc <- getFigCoords()
pc <- getFigCoords('p')
arrows(x0=pc[c(1,2,1,2)], x1=fc[c(1,2,1,2)],
    y0=pc[c(3,3,4,4)], y1=fc[c(3,3,4,4)], xpd=TRUE)
hc <-  getFigCoords('h')

# other options:
# 1. center of figure region:
abline(v=getFigCoords('hf')[1], col='blue', xpd=TRUE)
abline(h=getFigCoords('hf')[2], col='blue', xpd=TRUE)
# 2. center of plot region:
abline(v=getFigCoords('hp')[1], col='red', lty=3)
abline(h=getFigCoords('hp')[2], col='red', lty=3)

Run the code above in your browser using DataLab