Rev 4035 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{C_02_trellis.par.get}\alias{trellis.par.get}\alias{trellis.par.set}\alias{show.settings}\title{ Graphical Parameters for Trellis Displays }\description{Functions used to query, display and modify graphical parameters forfine control of Trellis displays. Modifications are made to thesettings for the currently active device only.}\usage{trellis.par.set(name, value, \dots, theme, warn = TRUE, strict = FALSE)trellis.par.get(name = NULL)% trellis.par.set(name, value, warn)% trellis.par.set(theme)% trellis.par.set(\dots)show.settings(x = NULL)}\arguments{\item{name}{ character giving the name of a component. If unspecified,\code{names(trellis.par.get())} returns a list containing all thecurrent settings (this can be used to get the valid values for\code{name})}\item{value}{a list giving the desired value of the component. Components thatare already defined as part of the current settings but are notmentioned in \code{value} will remain unchanged.}\item{theme}{a list decribing how to change the settings, similar to what isreturned by \code{trellis.par.get()}. This is purely forconvenience, allowing multiple calls to \code{trellis.par.set} to becondensed into one. The name of each component must be a valid\code{name} as described above, with the corresponding value a valid\code{value} as described above.As in \code{\link{trellis.device}}, \code{theme} can also be afunction that produces such a list when called. The function namecan be supplied as a quoted string.}\item{\dots}{Multiple settings can be specified in \code{name = value} form.Equivalent to calling with \code{theme = list(\dots)}}\item{warn}{logical, indicating whether a warning should be issued when\code{trellis.par.get} is called when no graphics device is open}\item{strict}{logical, indicating whether the \code{value} should be interpretedstrictly. Usually, assignment of value to the corresponding namedcomponent is fuzzy in the sense that sub-components that are absentfrom \code{value} but not currently \code{NULL} are retained. Byspecifying \code{strict = TRUE}, the assignment will be exact.}\item{x}{optional list of components that change the settings (any validvalue of \code{theme}). These are used to modify the currentsettings (obtained by \code{trellis.par.get}) before they aredisplayed.}}\details{The various graphical parameters (color, line type, background etc)that control the look and feel of Trellis displays are highlycustomizable. Also, R can produce graphics on a number of devices, andit is expected that a different set of parameters would be more suitedto different devices. These parameters are stored internally in avariable named \code{lattice.theme}, which is a list whose componentsdefine settings for particular devices. The components are idenifiedby the name of the device they represent (as obtained by\code{.Device}), and are created as and when new devices are openedfor the first time using \code{trellis.device} (or Lattice plots aredrawn on a device for the first time in that session).The initial settings for each device defaults to values appropriatefor that device. In practice, this boils down to three distinctsettings, one for screen devices like \code{x11} and \code{windows},one for black and white plots (mostly useful for \code{postscript})and one for color printers (color \code{postcript}, \code{pdf}).Once a device is open, its settings can be modified. When anotherinstance of the same device is opened later using\code{trellis.device}, the settings for that device are reset to itsdefaults, unless otherwise specified in the call to\code{trellis.device}. But settings for different devices are treatedseparately, i.e., opening a postscript device will not alter the x11settings, which will remain in effect whenever an x11 device isactive.The functions \code{trellis.par.*} are meant to be interfaces to theglobal settings. They always apply on the settings for the currentlyACTIVE device.\code{trellis.par.get}, called without any arguments, returns the fulllist of settings for the active device. With the \code{name} argumentpresent, it returns that component only. \code{trellis.par.get} setsthe value of the \code{name} component of the current active devicesettings to \code{value}.\code{trellis.par.get} is usually used inside trellis functions to getgraphical parameters before plotting. Modifications by users via\code{trellis.par.set} is traditionally done as follows:\code{add.line <- trellis.par.get("add.line")}\code{add.line$col <- "red"}\code{trellis.par.set("add.line", add.line)}More convenient (but not S compatible) ways to do this are\code{trellis.par.set(list(add.line = list(col = "red")))}and\code{trellis.par.set(add.line = list(col = "red"))}The actual list of the components in \code{trellis.settings} has notbeen finalized, so I'm not attempting to list them here. The currentvalue can be obtained by \code{print(trellis.par.get())}. Most namesshould be self-explanatory.\code{show.settings} provides a graphical display summarizing some ofthe values in the current settings.}\note{In some ways, \code{trellis.par.get} and \code{trellis.par.set}together are a replacement for the \code{\link{par}} function used intraditional R graphics. In particular, changing \code{par} settingshas little (if any) effect on lattice output. Since lattice plots areimplemented using Grid graphics, its parameter system \emph{does} havean effect unless overridden by a suitable lattice parameter setting.Such parameters can be specified as part of a lattice theme byincluding them in the \code{grid.pars} component (see\code{\link[grid:gpar]{gpar}} for a list of valid parameter names).One of the uses of \code{par} is to set \code{par(ask = TRUE)} makingR wait for user input before starting a new graphics page. For Gridgraphics, this is done using\code{\link[grid:grid.prompt]{grid.prompt}}. Lattice has no separateinterface for this, and the user must call \code{grid.prompt}directly. If the grid package is not attached (lattice itselfonly loads the grid namespace), this may be done using\code{grid::grid.prompt(TRUE)}.}\value{\code{trellis.par.get} returns a list giving parameters for thatcomponent. If \code{name} is missing, it returns the full list.}\author{ Deepayan Sarkar \email{Deepayan.Sarkar@R-project.org}}\seealso{\code{\link{trellis.device}}, \code{\link{Lattice}},\code{\link[grid:grid.prompt]{grid.prompt}},\code{\link[grid:gpar]{gpar}}}\examples{show.settings()}\keyword{dplot}