viewportTransform {grid} R Documentation

Define a Group Transformation

Description

These functions define the transformation that will be applied when a grid.define()d group is grid.use()d.

Usage

viewportTransform(group, shear=groupShear(), flip=groupFlip(), ...)
viewportTranslate(group, ...)
viewportScale(group, ...)
viewportRotate(group, ...)
defnTranslate(group, inverse=FALSE, ...)
defnScale(group, inverse=FALSE, ...)
defnRotate(group, inverse=FALSE, ...)
useTranslate(group, inverse=FALSE, ...)
useScale(group, inverse=FALSE, ...)
useRotate(group, inverse=FALSE, ...)
groupTranslate(dx=0, dy=0)
groupRotate(r=0)
groupScale(sx=1, sy=1)
groupShear(sx=0, sy=0)
groupFlip(flipX=FALSE, flipY=FALSE)

Arguments

 group The group that is being transformed. inverse A logical indicating whether we want the forward or backward transformation. shear An affine transformation matrix that describes a shear transformation. flip An affine transformation matrix that describes a scaling inversion. dx, dy The translation to apply. r The rotation to apply. sx, sy The scaling (or shear) to apply. flipX, flipY Whether to negate the x-scaling or y-scaling (logical). ... Arguments passed on to lower-level transformation functions.

Details

The viewport*() functions are not called directly. They are passed as the transform argument to grid.use.

The defn*() and use*() functions are also not called directly, but can be useful to create custom transformation functions. For example, see the source code for viewportTransform.

The group*() functions generate basic affine transformation matrices and may also be useful to create custom transformation functions. For example, the groupShear() function can be used to specify a shear transform to viewportTransform().

It is also possible to define any function that returns a 4x4 matrix and use it as the transform argument to grid.use, but the results will probably be device-dependent may be very difficult to predict.

Value

An affine transformation matrix.

Paul Murrell

Examples

## NOTE: on devices without support for groups nothing will be drawn
grid.newpage()
## Define and use group in same viewport
pushViewport(viewport(width=.2, height=.2))
grid.define(circleGrob(gp=gpar(lwd=5)), name="circle")
grid.use("circle")
popViewport()
## Use group in viewport that is translated and scaled
pushViewport(viewport(x=.2, y=.2, width=.1, height=.1))
grid.use("circle")
popViewport()
## Use group in viewport that is translated and scaled
## BUT only make use of the translation
pushViewport(viewport(x=.2, y=.8, width=.1, height=.1))
grid.use("circle", transform=viewportTranslate)
popViewport()
## Use group in viewport that is translated and scaled
## unevenly (distorted)
pushViewport(viewport(x=.8, y=.7, width=.2, height=.4))
grid.use("circle")
popViewport()

[Package grid version 4.2.0 Index]