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

Greg.Snow at intermountainmail.org Greg.Snow at intermountainmail.org
Tue Mar 6 17:56:44 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
started.

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

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




More information about the R-devel mailing list