[R] Default par() options

Petr Klasterecky klaster at karlin.mff.cuni.cz
Thu Mar 1 21:50:56 CET 2007


I am no expert on these topics but currently I am solving a similar 
issue using the .Rprofile file and the .First function. So maybe it's 
enough to put
.First <- function(){
par(whatever you want)
further instructions if neccessary
}

Petr

Thomas Friedrichsmeier napsal(a):
> 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 
> plot:
> 
> 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 
> command.
> 
> 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").
> 
> Regards
> Thomas Friedrichsmeier
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic



More information about the R-help mailing list