[R] Are there better ways to save and restore par() settings
murdoch.duncan at gmail.com
Fri May 14 23:45:42 CEST 2010
On 14/05/2010 3:51 PM, David Winsemius wrote:
> Some of the help page examples use the form:
> opar <- par(<something>)
> .....plotting activities...
> This seems to "work" well, yet I have read in some places
Please include commented, retrievalbe citations for "some places".
> that it is
> not the preferred method to keep you parameters from getting
> corrupted. What is the preferred method?
The above, with the restore wrapped in on.exit(), as your sources should
> A worked example from a recent posting with minor additions:
> opar <- par(mar=c(3,5,0,5))
> layout(rbind(c(4,1,1,5), c(2,2,3,3)), widths=c(1,1,1,1),
> barplot(0,0, axes=FALSE)
> legend(x=0.5, y=0, legend=c("Example 1", "Example 2"),
> pch=c(1,2), cex=1.5, xjust=1, yjust=0.5, bty="n")
> plot(1:10,1:10, pch=1)
> plot(1:20,1:20, pch=2)
More information about the R-help