\HeaderA{clip}{Set Clipping Region}{clip}
\keyword{dplot}{clip}
\begin{Description}\relax
Set clipping region in user coordinates
\end{Description}
\begin{Usage}
\begin{verbatim}
clip(x1, x2, y1, y2)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x1, x2, y1, y2}] user coordinates of clipping rectange
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
How the clipping rectangle is set depends on the setting of
\code{\LinkA{par}{par}("xpd")}: this function changes the current setting
until the next high-level plotting command resets it.

Exactly when the clipping region will be reset can be hard to
predict.  \code{\LinkA{plot.new}{plot.new}} always resets it.
Functions such as \code{\LinkA{lines}{lines}} and \code{\LinkA{text}{text}} only
reset it if \code{\LinkA{par}{par}("xpd")} has been changed.  However,
functions such as \code{\LinkA{box}{box}}, \code{\LinkA{mtext}{mtext}},
\code{\LinkA{title}{title}} and \code{\LinkA{plot.dendrogram}{plot.dendrogram}} can manipulate
the \code{xpd} setting.
\end{Details}
\begin{SeeAlso}\relax
\code{\LinkA{par}{par}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- rnorm(1000)
hist(x, xlim=c(-4,4))
usr <- par("usr")
clip(usr[1], -2, usr[3], usr[4])
hist(x, col = 'red', add = TRUE)
clip(2, usr[2], usr[3], usr[4])
hist(x, col = 'blue', add = TRUE)
do.call("clip", as.list(usr))  # reset to plot region
\end{ExampleCode}
\end{Examples}

