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

Gabor Grothendieck ggrothendieck at gmail.com
Wed Mar 7 18:04:52 CET 2007


Here are a few ideas:

For #1 define:

"$.Par" <- function(x, FUN) {
   par.default <- getOption("par.default")
   if (!is.null(par.default)) do.call("par", par.default)
   get(FUN, parent.frame())
}
Par <- structure(NA, class = "Par")

# and now one can preface any function with Par$ and it will
# call par and then the function.  This eliminates an extra statement
# but does mean you have to preface plot, say, with Par$
# e.g.

options(par.default = list(bg = "light gray", las = 2))
Par$plot(1:10)
Par$boxplot(1:10)


For #2 do:

plot <- Par$plot


Another idea for #2 is to use the connect package.  See:
http://code.google.com/p/r-connect/


On 3/6/07, thomas.friedrichsmeier at ruhr-uni-bochum.de
<thomas.friedrichsmeier at ruhr-uni-bochum.de> wrote:
> Full_Name: Thomas Friedrichsmeier
> Version: 2.4.1
> OS: linux (Debian unstable)
> Submission from: (NULL) (84.60.113.185)
>
>
> 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