[Rd] Wish: Option to configure the default par() (PR#9545)

Greg Snow Greg.Snow at intermountainmail.org
Tue Mar 6 17:56:11 CET 2007

Another approach may be to use hooks (see ?setHook).  The plot.new
function already has a hook, so you could do your option #1
automatically by setting that hook.

Better would be if all the graphics device functions had hooks (or a
common hook), then you could set that hook to set your graphics
parameters and they would be set every time a new graphics device was

Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111

> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of 
> thomas.friedrichsmeier at ruhr-uni-bochum.de
> Sent: Tuesday, March 06, 2007 7:04 AM
> To: r-devel at stat.math.ethz.ch
> Cc: R-bugs at biostat.ku.dk
> Subject: [Rd] Wish: Option to configure the default par() (PR#9545)
> Full_Name: Thomas Friedrichsmeier
> Version: 2.4.1
> OS: linux (Debian unstable)
> Submission from: (NULL) (
> Summary: It would be nice to have a centralized option for 
> setting default par() options for all devices and all plots. 
> This would ease producing graphs in a customized but 
> consistent way. Suggesting options("par.default").
> Example problem: Make all graphs look like
> par(bg="light gray", las=2)
> both on screen and for various produced file formats such as 
> png() and postscript().
> Current situation: To solve the example problem, two 
> approaches come to mind:
> 1) Always call par() before the next plot. This could be 
> wrapped into a function to make it easier to stay consistent. E.g.:
> postscript()
> myDefaultPar()       # calls par(bg="light gray", las=2)
> plot(...)
> 2) Create wrappers for all devices of interest, like e.g. 
> (not quite correct, but good enough for this example):
> myX11 <- function(...) {
>   X11(...)
>   par(bg="light gray", las=2)
> }
> Both solutions work, but are not entirely elegant. The 
> drawback of 1) is that you still need to add the given line 
> manually at all places. The drawback of 2) is that a similar 
> wrapper will have to be created (and used) for each different device.
> Wish:
> Add a new option: options("par.default"), similar to the 
> existing options("par.ask.default"). This option would accept 
> a list of all par settings to set a custom default for:
> options(par.default=list(bg="light gray", las=2))
> par() options specified while creating the device, in calls 
> to plot() or in subsequent calls to par() would take 
> precendence over options("par.default").
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list