Learn R Programming

playwith (version 0.8.39)

rawXLim: Get or set current plot limits

Description

Part of the playwith Application Programming Interface.

Usage

rawXLim(playState, space = "plot")
rawYLim(playState, space = "plot")
rawXLim(playState) <- value
rawYLim(playState) <- value

Arguments

playState
a playState object representing the plot, window and device.
space
character, the plot space for which to get or set limits. See the space argument to playDo; however, in this case, space="plot" will always return a value: if it is a Latt
value
numeric length 2, the new nominal x or y limits (for xlim or ylim plot arguments).

Value

  • the extractor form returns the x or y plot limits as numeric length 2.

Details

rawXLim returns the current plot limits, on a numeric, linear scale. This is as simple as: playDo(playState, space=space, list( x=convertX(unit(0:1, "npc"), "native", valueOnly=TRUE), y=convertY(unit(0:1, "npc"), "native", valueOnly=TRUE))) except that the default space="plot" will always return a value: if it is a Lattice plot with multiple panels, one will be chosen arbitrarily. The assignment form converts a numeric range, in the raw native plot coordinates, to values suitable for the plot xlim argument: it may convert back from log-transformed scales, and convert to factor levels if necessary. It then updates the current plot call with the new value.

See Also

playwith.API

Examples

Run this code
if (interactive()) {

playwith(plot(1:10, log="x"))
playState <- playDevCur()
rawXLim(playState)  # -0.04  1.04
rawXLim(playState) <- c(0, 2)
playReplot(playState)
## now xlim=c(1, 100)
rawXLim(playState)  # -0.08  2.08

}

Run the code above in your browser using DataLab