# R: Get the Current Grid Viewport (Tree)

Querying the Viewport Tree {grid} | R Documentation

## Get the Current Grid Viewport (Tree)

### Description

`current.viewport()` returns the viewport that Grid is going to draw into.

`current.vpTree` returns the entire Grid viewport tree.

`current.vpPath` returns the viewport path to the current viewport.

`current.transform` returns the transformation matrix for the current viewport.

### Usage

    current.viewport(vp=NULL)
    current.vpTree(all=TRUE)
    current.vpPath()
    current.transform()

### Arguments

`vp` | A Grid viewport object. Use of this argument has been deprecated.
`all` | A logical value indicating whether the entire viewport tree should be returned.

### Details

If `all` is `FALSE` then `current.vpTree` only returns the subtree below the current viewport.

### Value

A Grid viewport object from `current.viewport` or `current.vpTree`.
`current.transform` returns a 4x4 transformation matrix.
The viewport path returned by `current.vpPath` is `NULL` if the current viewport is the `ROOT` viewport

### Author(s)

Paul Murrell

### See Also

`viewport`

### Examples

    grid.newpage()
    pushViewport(viewport(width=0.8, height=0.8, name="A"))
    pushViewport(viewport(x=0.1, width=0.3, height=0.6,
      just="left", name="B"))
    upViewport(1)
    pushViewport(viewport(x=0.5, width=0.4, height=0.8,
      just="left", name="C"))
    pushViewport(viewport(width=0.8, height=0.8, name="D"))
    current.vpPath()
    upViewport(1)
    current.vpPath()
    current.vpTree()
    current.viewport()
    current.vpTree(all=FALSE)
    popViewport(0)

[Package grid version 2.6.0 Index]