convertFromDevicePixels

0th

Percentile

Utilities for working with grobs and viewports in device coordinates.

Utilities for working with grobs and viewports in device coordinates.

Keywords
iplot , dplot
Usage
convertFromDevicePixels(x.px, y.px, unitTo = "native", valueOnly = FALSE) convertToDevicePixels(x, y)
inViewport(x.px, y.px, viewport) grobBBDevicePixels(grob, viewport, pad = 2)
grobBoundingBoxes(draw = TRUE, gp.box = gpar(col = "yellow", lwd = 5, alpha = 0.2), gp.text = gpar(cex = 0.75, alpha = 0.5))
Arguments
x.px, y.px
locations in device coordinates (i.e. pixels, with origin at top-left corner of device). May be vectors.
unitTo
the unit to convert to.
valueOnly
to return values as numeric (native) rather than units.
x, y
locations in the current viewport (numeric native or units). May be vectors.
viewport
a viewport name or vpPath.
grob
a grob.
pad
number of pixels to expand bounding boxes.
draw
whether to draw bounding boxes and grob names.
gp.box
graphical parameters for bounding boxes.
gp.text
graphical parameters for grob name text.
Details

Not yet...

Value

convertFromDevicePixels returns a list with x, y (units or numeric) locations in the current viewport.convertToDevicePixels returns a list with x, y (numeric) locations in pixels from the top-left corner of the device.inViewport returns a logical: whether the given pixel location is inside the given viewport.grobBBDevicePixels returns a list with x, y (numeric) locations in pixels giving the bounding box of the given grob. The grob must exist in the given viewport.grobBoundingBoxes returns a data.frame giving information about all grobs in the current scene.

See Also

grid.convert, grobX, grid.ls, grid.show.layout

Aliases
  • convertFromDevicePixels
  • convertToDevicePixels
  • inViewport
  • grobBBDevicePixels
  • grobBoundingBoxes
  • showGrobsBB
Examples
print(xyplot(1:10 ~ 1:10 | c("a", "b")))

vpname <- trellis.vpname("panel", 1, 1)
downViewport(vpname)

convertToDevicePixels(x = 5:10, y = 5:10)
convertToDevicePixels(unit(0, "npc"), unit(0, "npc"))
convertFromDevicePixels(x = 100, y = 100)

inViewport(x = 100, y = 100, vpname)
inViewport(x = c(0, 100), y = c(0, 100), vpname)

myGrob <- grid.circle(r = 0.3, name = "myCircle")
grobBBDevicePixels(myGrob, vpname)

str(grobBoundingBoxes(draw = TRUE))
Documentation reproduced from package playwith, version 0.9-54, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.