[R] Are there better ways to save and restore par() settings

David Winsemius dwinsemius at comcast.net
Fri May 14 21:51:21 CEST 2010

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 that it is  
not the preferred method to keep you parameters from getting  
corrupted. What is the preferred method?

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)

David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list