convertNative {grid} | R Documentation |
This function returns a numeric vector containing the specified x or y locations or dimensions, converted to "user" or "data" units, relative to the current viewport.
convertNative(unit, dimension="x", type="location")
unit |
A unit object. |
dimension |
Either "x" or "y". |
type |
Either "location" or "dimension". |
A numeric vector.
If you draw objects based on output from these conversion functions, then resize your device, the objects will be drawn incorrectly the base R display list will not recalculate these conversions. This means that you can only rely on the results of these calculations if the size of your device is fixed.
Paul Murrell
grid.newpage() push.viewport(viewport(width=unit(.5, "npc"), height=unit(.5, "npc"))) grid.rect() w <- convertNative(unit(1, "inches")) h <- convertNative(unit(1, "inches"), "y") # This rectangle starts off life as 1in square, but if you # resize the device it will no longer be 1in square grid.rect(width=unit(w, "native"), height=unit(h, "native"), gp=gpar(col="red")) pop.viewport(1)