Martin Maechler
2004-Jun-26 22:00 UTC
[Rd] Re: plot.new() warning from coplot()'s par(*, new=FALSE)
{diverted from the R-SIG-gui list}>>>>> "PD" == Peter Dalgaard <p.dalgaard@biostat.ku.dk> >>>>> on 26 Jun 2004 11:51:02 +0200 writes:PD> James Wettenhall <wettenhall@wehi.edu.au> writes: >> Hi, >> >> Does anyone know a good way to get rid of warnings like: >> Warning message: calling par(new=) with no plot >> >> when using an R plot function which calls plot.new() >> (e.g. coplot) from within tkrplot? >> ..... PD> Hmm, the same wart appears if you just plot to a freshly PD> opened X11 device (X11(); coplot(....)), nothing PD> specific to tkrplot. I think I've seen this reported PD> before, but I have forgotten what the recommended action PD> was. If I look at coplot, I see that it's very first graphics call is par(mfrow =..................., new = FALSE) and this ('new = FALSE') of course gives the warning when no graphic device is active. coplot()'s code is just not quite right here IMO. I can rid of the warning and keep coplot() behaving as now otherwise by replacing opar <- par(mfrow = c(total.rows, total.columns), oma = oma, mar = mar, xaxs = "r", yaxs = "r", new = FALSE) by if(dev.cur() > 1 && par("new")) # turn off a par(new=TRUE) setting par(new = FALSE) opar <- par(mfrow = c(total.rows, total.columns), oma = oma, mar = mar, xaxs = "r", yaxs = "r") - - - and I'd commit this (to R-patched). OTOH, I wonder if we couldn't just omit the if(...) par(new = FALSE) clause {for R-devel at least}. If a user really calls par(new = TRUE) before calling coplot() (s)he should be allowed to produce such a monstrosity --- unless its an ingenuosity such as drawing a background image on which to draw coplot() ... Martin Maechler