[R] Default par() options

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Thu Mar 1 20:40:41 CET 2007

The following question/idea came up on the RKWard development mailing list, 
but might be of general interest:

Is there a nice way to customize the default look of all graphs on all 
devices? I.e. a way to - for instance - set the following options before each 

par(bg="light gray", las=2, pch=19)

As far as I have found, there would currently be two ways to do this:
1) Adding the above statement manually after opening the device, and before 
starting the plot. It could of course be wrapped inside a custom function to 
save some typing, but you'd still need to make sure to always add the 

2) Overriding all device functions with something like:
X11 <- function (...) {
	grDevices::X11 (...)
	par ([custom options])
This would be feasible, but feels rather dirty. Also, something substantially 
more elaborate would be needed to honor e.g. fonts and bg arguments, if 
explicitely specified in the call to X11. Would have to be done for each 
device separately.

Does a third, more elegant solution exist?

If not, would the following idea have any chances of being added to R?

Create a new options("par.default"), similar to the already existing 
options("par.ask.default"). This would take a list of par() options to set a 
default value for, like e.g.:

options(par.default=list(bg="light gray", las=2, pch=19))

Only those options would need to be specified in the list, for which you 
actually want to set a default different from the built-in. Options 
explicitely specified in X11(), plot(), additional calls to par(), etc. would 
take precedence over options("par.default").

Thomas Friedrichsmeier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20070301/13fb8bea/attachment.bin 

More information about the R-help mailing list