[R] resetting par() to all defaults: par(reset=TRUE) ?

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Sep 30 20:03:54 CEST 2007


On Sun, 30 Sep 2007, bbolker wrote:

> Michael Friendly wrote:
>>
>> In a long session, producing multiple graphs, I sometimes repeatedly
>> change par() settings, particularly with multi-row/col displays.
>> If I'm using a script, I'll do
>>
>> op <- par(newsettings)
>> ... plots ...
>> par(op)
>>
>> but sometimes I do things on the fly and can't easily back out
>> to the default settings.  I'm looking for someway to do the
>> equivalent of
>>
>> par(reset=TRUE)
>>
>> I suppose I could do something like create Rprofile.site containing
>>
>> .First <- function() par.default <- par()
>>
>> and then par(par.default), but maybe there's an easier way I haven't
>> noticed.  [On Windows, I don't use Rprofile.site because it's one more
>> thing to update with each new version.]
>>
>> -Michael
>>
>
>  Your solution seems pretty good to me (although I often use Deepayan's
> dev.off(); windows() hack myself), but I would amend it to
> par.default <- par(no.readonly=TRUE)

The default parameters depend on the device and indeed on the size of the 
device.  Deepayan's suggestion (as I recall he did not suggest opening the 
device but letting R do it) is widely used and seems a lot better to me, 
not least because setting par() in .First will open a device in every 
session, needed or not, interactive or not.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list