[R] par() usage

Marc Schwartz MSchwartz at MedAnalytics.com
Tue Mar 23 18:47:39 CET 2004


On Tue, 2004-03-23 at 08:53, Timur Elzhov wrote:
> Dear R experts.
> 
> I saw in a lot of examples the following R code:
> 
>     x11()
>     op <- par(no.readonly = TRUE)
>     par(op)
>         Warning message: 
>         calling par(new=) with no plot 
> 
> Why I get a warning? I'm doing something wrong?
> Thank you!


You have not created any type of plot yet, prior to calling par(op),
which restores the values of the non-readonly pars you saved in your
second line. You simply opened a plotting device with the call to x11()
in the first line.

The error message is indicating that you are trying to set/reset
par("new") without a plot having been created first. In par.c, which is
the relevant source code file for the par() function, there is a check
in the code to inhibit this sequence.

par("new") is used to define whether or not a _new_ plot will overwrite
an _existing_ plot. You have no existing plot.

You might want to look at ?par for examples of how to use the sequence
of saving and restoring the non-readonly parameters. It is typically
done when you will be modifying certain plot parameters and wish to
restore them to a default state later when you are done.

HTH,

Marc Schwartz




More information about the R-help mailing list