Learn R Programming

graphics (version 3.6.0)

convertXY: Convert between Graphics Coordinate Systems

Description

Convert between graphics coordinate systems.

Usage

grconvertX(x, from = "user", to = "user")
grconvertY(y, from = "user", to = "user")

Arguments

x, y

numeric vector of coordinates.

from, to

character strings giving the coordinate systems to convert between.

Value

A numeric vector of the same length as the input.

Details

The coordinate systems are

"user"

user coordinates.

"inches"

inches.

"device"

the device coordinate system.

"ndc"

normalized device coordinates.

"nfc"

normalized figure coordinates.

"npc"

normalized plot coordinates.

"nic"

normalized inner region coordinates. (The ‘inner region’ is that inside the outer margins.)

"lines"

lines of margin (based on mex).

"chars"

lines of text (based on cex).

(These names can be partially matched.) For the ‘normalized’ coordinate systems the lower left has value 0 and the top right value 1.

Device coordinates are those in which the device works: they are usually in pixels where that makes sense and in big points (1/72 inch) otherwise (e.g., pdf and postscript).

Examples

Run this code
# NOT RUN {
op <- par(omd=c(0.1, 0.9, 0.1, 0.9), mfrow = c(1, 2))
plot(1:4)
for(tp in c("in", "dev", "ndc", "nfc", "npc", "nic", "lines", "chars"))
    print(grconvertX(c(1.0, 4.0), "user", tp))
par(op)
# }

Run the code above in your browser using DataLab