Rev 64662 | Rev 85983 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/grid/man/grid.ls.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2013 R Core Team% Distributed under GPL 2 or later\name{grid.ls}\alias{grid.ls}\alias{nestedListing}\alias{pathListing}\alias{grobPathListing}\title{ List the names of grobs or viewports }\description{Return a listing of the names of grobs or viewports.This is a generic function with methods for grobs (includinggTrees) and viewports (including vpTrees).}\usage{grid.ls(x=NULL, grobs=TRUE, viewports=FALSE, fullNames=FALSE,recursive=TRUE, print=TRUE, flatten=TRUE, ...)nestedListing(x, gindent=" ", vpindent=gindent)pathListing(x, gvpSep=" | ", gAlign=TRUE)grobPathListing(x, ...)}\arguments{\item{x}{A grob or viewport or \code{NULL}. If \code{NULL}, the currentgrid display list is listed.For print functions, this should be the result of a call to\code{grid.ls}.}\item{grobs}{A logical value indicating whether to list grobs.}\item{viewports}{A logical value indicating whether to listviewports.}\item{fullNames}{A logical value indicating whether to embellishobject names with information about the object type.}\item{recursive}{A logical value indicating whether recursivestructures should also list their children.}\item{print}{A logical indicating whether to print the listingor a function that will print the listing.}\item{flatten}{A logical value indicating whether to flattenthe listing. Otherwise a more complex hierarchical object isproduced.}\item{gindent}{The indent used to show nesting in the output forgrobs.}\item{vpindent}{The indent used to show nesting in the output forviewports.}\item{gvpSep}{The string used to separate viewport paths from grobpaths.}\item{gAlign}{Logical indicating whether to align the left handedge of all grob paths.}\item{...}{Arguments passed to the \code{print} function.}}\details{If the argument \code{x} is \code{NULL}, the current contentsof the grid display list are listed (both viewports and grobs).In other words, all objects representing the current sceneare listed.Otherwise, \code{x} should be a grob or a viewport.The default behaviour of this function is to print informationabout the grobs in the current scene. It is also possible toadd information about the viewports in the scene. By default,the listing is recursive, so all children of gTrees and allnested viewports are reported.The format of the information can be controlled via the \code{print}argument, which can be given a function to perform the formatting.The \code{nestedListing} function produces a line per grob orviewport, with indenting used to show nesting. The \code{pathListing}function produces a line per grob or viewport, with viewport pathsand grob paths used to show nesting. The \code{grobPathListing}is a simple derivation that only shows lines for grobs. The usercan define new functions.}\value{The result of this function is either a \code{"gridFlatListing"}object (if \code{flatten} is \code{TRUE}) or a \code{"gridListing"}object.The former is a simple (flat) list of vectors. This is convenient,for example,for working programmatically with the list of grob and viewportnames, or for writing a new display function for the listing.The latter is a more complex hierarchical object (list of lists),but it does contain more detailed information so may be of use formore advanced customisations.}\seealso{\code{\link{grob}}\code{\link{viewport}}}\author{ Paul Murrell }\examples{# A gTree, called "parent", with childrenvp vpTree (vp2 within vp1)# and child grob, called "child", with vp vpPath (down to vp2)sampleGTree <- gTree(name="parent",children=gList(grob(name="child", vp="vp1::vp2")),childrenvp=vpTree(parent=viewport(name="vp1"),children=vpList(viewport(name="vp2"))))grid.ls(sampleGTree)# Show viewports toogrid.ls(sampleGTree, view=TRUE)# Only show viewportsgrid.ls(sampleGTree, view=TRUE, grob=FALSE)# Alternate displays# nested listing, custom indentgrid.ls(sampleGTree, view=TRUE, print=nestedListing, gindent="--")# path listinggrid.ls(sampleGTree, view=TRUE, print=pathListing)# path listing, without grobs alignedgrid.ls(sampleGTree, view=TRUE, print=pathListing, gAlign=FALSE)# grob path listinggrid.ls(sampleGTree, view=TRUE, print=grobPathListing)# path listing, grobs onlygrid.ls(sampleGTree, print=pathListing)# path listing, viewports onlygrid.ls(sampleGTree, view=TRUE, grob=FALSE, print=pathListing)# raw flat listingstr(grid.ls(sampleGTree, view=TRUE, print=FALSE))}\keyword{ dplot }