[R] set par options once for entire R session

Jim Lemon drjimlemon at gmail.com
Thu Jun 25 13:01:34 CEST 2015


Hi Martin,
Depending upon what device parameters you want to set, you can write a
wrapper for the device call that includes the parameters:

my.x11<-function() {
 x11(family="sans",font=2)
}

Then just call the wrapper instead of the device function. You could
make a little package with all of the devices you wish to use and just
load the package at the beginning of your R session.

Jim


On Thu, Jun 25, 2015 at 1:40 AM, MacQueen, Don <macqueen1 at llnl.gov> wrote:
> The Details section of ?par starts of with:
>
>  "Each device has its own set of graphical parameters."
>
> (So this is not Mac-specific.)
>
> Strictly speaking, the options you set with par() are not "reset" when you
> open a new graphics device. Rather, when a new device is opened, it is
> initialized with default values of graphics parameters.
>
> If you can find where those default values are stored (in a brief search I
> did not find them), then perhaps you can change them at session startup
> time.
>
> I haven't tested this, but you might be able to make things a little more
> convenient by defining a function
>
>   mypar <- function() par( {set whatever values you want} )
>
> Then whenever you open a new device, immediately call that function:
>
> pdf()
> mypar()
> plot(x,y)
> dev.off()
>
> png()
> mypar()
> plot(x,y)
> dev.of()
>
> And so on.
>
>
>
> --
> Don MacQueen
>
> Lawrence Livermore National Laboratory
> 7000 East Ave., L-627
> Livermore, CA 94550
> 925-423-1062
>
>
>
>
>
> On 6/23/15, 8:54 AM, "R-help on behalf of Martin Batholdy via R-help"
> <r-help-bounces at r-project.org on behalf of r-help at r-project.org> wrote:
>
>>Hi,
>>
>>I would like to set plot-options via par() and keep them for all plots
>>that are created thereafter.
>>Currently after each plot device the parameters I can set with par() are
>>reseted to their default value, at least on a Mac (R 3.2.1).
>>
>>Is there a way to define the parameters for plotting once at the
>>beginning and then keep them for an entire R session?
>>
>>
>>Thank you!
>>
>>______________________________________________
>>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>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.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list