\HeaderA{gpar}{Handling Grid Graphical Parameters}{gpar}
\aliasA{get.gpar}{gpar}{get.gpar}
\keyword{dplot}{gpar}
\begin{Description}\relax
\code{gpar()} should be used to create a set of graphical
parameter settings.  It returns an object of class \code{"gpar"}.  This is
basically a list of name-value pairs.

\code{get.gpar()} can be used to query the current
graphical parameter settings.
\end{Description}
\begin{Usage}
\begin{verbatim}
gpar(...)
get.gpar(names = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] Any number of named arguments. 
\item[\code{names}] A character vector of valid graphical parameter names.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
All grid viewports and (predefined) graphical objects have a slot
called \code{gp}, which contains a \code{"gpar"} object.  When
a viewport is pushed onto the viewport stack and when a graphical object
is drawn, the settings in the \code{"gpar"} object are enforced.
In this way, the graphical output is modified by the \code{gp}
settings until the graphical object has finished drawing, or until the
viewport is popped off the viewport stack, or until some other
viewport or graphical object is pushed or begins drawing.

Valid parameter names are:
\Tabular{ll}{
col & Colour for lines and borders. \\
fill & Colour for filling rectangles, polygons, ... \\
alpha & Alpha channel for transparency \\
lty & Line type \\
lwd & Line width \\
lex & Multiplier applied to line width \\
lineend & Line end style (round, butt, square) \\
linejoin & Line join style (round, mitre, bevel) \\
linemitre & Line mitre limit (number greater than 1) \\
fontsize & The size of text (in points) \\
cex & Multiplier applied to fontsize \\
fontfamily & The font family \\
fontface & The font face (bold, italic, ...) \\
lineheight & The height of a line as a multiple of the size of text \\
font & Font face (alias for fontface;  for
backward compatibility) \\
}

Colours can be specified in one of the forms returned by
\code{\LinkA{rgb}{rgb}}, as a name (see \code{\LinkA{colors}{colors}}) or as a
positive integer index into the current \LinkA{palette}{palette} (with zero or
negative values being taken as transparent).

The \code{alpha} setting is combined with the alpha channel for
individual colours by multiplying (with both alpha settings
normalised to the range 0 to 1).

The size of text is \code{fontsize}*\code{cex}.  The size of a line
is \code{fontsize}*\code{cex}*\code{lineheight}.

The \code{cex} setting is cumulative;  if a viewport is pushed
with a \code{cex} of 0.5 then another viewport is pushed with a
\code{cex} of 0.5, the effective \code{cex} is 0.25.

The \code{alpha} and \code{lex} settings are also cumulative.

Changes to the \code{fontfamily} may be ignored by some devices,
but is supported by PostScript, PDF, X11, Windows, and Quartz.  The
\code{fontfamily} may be used to specify one
of the Hershey Font families (e.g., \code{HersheySerif})
and this specification will be honoured
on all devices.

The specification of \code{fontface} can be an integer or a string.
If an integer, then it
follows the R base graphics
standard:  1 = plain, 2 = bold, 3 = italic, 4 = bold italic.
If a string, then valid values are: \code{"plain"},
\code{"bold"}, \code{"italic"}, \code{"oblique"}, and
\code{"bold.italic"}.
For the special case of the HersheySerif font family,
\code{"cyrillic"}, \code{"cyrillic.oblique"}, and \code{"EUC"}
are also available.

Specifying the value \code{NULL} for a parameter is the same as not
specifying any value for that parameter, except for \code{col} and
\code{fill}, where \code{NULL} indicates not to draw a border or
not to fill an area (respectively).

All parameter values can be vectors of multiple values.  (This will
not always make sense -- for example, viewports will only take
notice of the first parameter value.)

The \code{gamma} parameter is defunct since \R{} 2.7.0.

\code{get.gpar()} returns all current graphical parameter settings.
\end{Details}
\begin{Value}
An object of class \code{"gpar"}.
\end{Value}
\begin{Author}\relax
Paul Murrell
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{Hershey}{Hershey}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
gp <- get.gpar()
utils::str(gp)
## These *do* nothing but produce a "gpar" object:
gpar(col = "red")
gpar(col = "blue", lty = "solid", lwd = 3, fontsize = 16)
get.gpar(c("col", "lty"))
grid.newpage()
vp <- viewport(w = .8, h = .8, gp = gpar(col="blue"))
grid.draw(gTree(children=gList(rectGrob(gp = gpar(col="red")),
                     textGrob(paste("The rect is its own colour (red)",
                                    "but this text is the colour",
                                    "set by the gTree (green)",
                                    sep = "\n"))),
      gp = gpar(col="green"), vp = vp))
grid.text("This text is the colour set by the viewport (blue)",
          y = 1, just = c("center", "bottom"),
          gp = gpar(fontsize=20), vp = vp)
grid.newpage()
## example with multiple values for a parameter
pushViewport(viewport())
grid.points(1:10/11, 1:10/11, gp = gpar(col=1:10))
popViewport()
\end{ExampleCode}
\end{Examples}

