maechler@stat.math.ethz.ch
2002-Nov-13 17:48 UTC
Wandering usr values in par(no.readonly=TRUE) (PR#2283)
>>>>> "Marc" == Marc Schwartz <mschwartz@medanalytics.com> >>>>> on Wed, 13 Nov 2002 11:01:49 -0600 writes:Marc> Marc Schwartz wrote: >> SNIP >> >> I am guessing that this may be the result of par("ylog") >> and par("xlog") being read only and perhaps impacting the >> restoration of the par("usr") values when the plotting >> device is still open, but that may be incorrect. Marc> In follow up to my own note from last evening on this Marc> and now that I have had a couple of cups of coffee Marc> this morning, I need to partially correct my above Marc> statement and point to a presumed typo in the ?par Marc> help file. For confirmation, this is R 1.6.1 under Marc> WinXP Pro. Marc> par("xlog") and par("ylog") are not Read Only Marc> parameters as listed in the help file and can be set Marc> by the user. Indeed this is confirmed in the comments Marc> in par.r: Marc> #.Pars.readonly <- c("cin","cra","csi","cxy","din") Marc> I noted this today as I was comparing the output of Marc> par() with par(no.readonly = TRUE) and noted that the Marc> latter returns '$xlog' and $ylog' as being Marc> settable. The other 5 par values listed in ?par as Marc> "R.O." (cin, cra, csi, cxy and din) return errors when Marc> one attempts to set them with par(args), however xlog Marc> and ylog do not. Yes, indeed, and I -- as an R-core member -- am astonished:. I didn't know it really worked, but it does, e.g., > plot(1:10); par("usr") [1] 0.64 10.36 0.64 10.36 > par(xlog = TRUE); par(c("xlog","usr")) $xlog [1] TRUE $usr [1] -0.1938200 1.0153598 0.6400000 10.3600000 > points(10^(1:9), 1 + 1:9, col = "red") # draws red points above I'm now re-directing this back to R-bugs to make sure that the only (right?) remaining bug, documentation in par.Rd, will be fixed -- and hope to close this as a bug report. Marc> .......... Marc> <more good analysis> Thank you Marc! Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Marc Schwartz
2002-Nov-13 19:08 UTC
Wandering usr values in par(no.readonly=TRUE) (PR#2283)
Martin wrote:> SNIP > > Thank you Marc!Glad to be of help Martin. For the sake of completeness, I ran the same examples on my Linux (RH 8) install of R 1.6.1 and observed the same behavior. Best regards, Marc Schwartz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Marc Schwartz
2002-Nov-13 23:06 UTC
Wandering usr values in par(no.readonly=TRUE) (PR#2283)
Martin wrote:> I'm now re-directing this back to R-bugs to make sure that > the only (right?) remaining bug, documentation in par.Rd, > will be fixed -- and hope to close this as a bug report.Martin, My apologies, as I may have missed this in my first reading of your reply, but I wanted to be sure that it was clear that there are two separate bugs here. The first, which I found this morning in the process of tracking down Jari's issue and the second which Jari observed in his initial post, which started this thread yesterday. Bug 1. The documentation in par.Rd needs to be corrected in that par("xlog") and par("ylog") are not R.O. I presume that this is what you are referring to above. Bug 2. The improper restoration of par("usr") from saved values after using log scaled axes. This is a result of the sequence of the code in the par.c Specify() function (ie. par("usr") being set before par("xlog") and par("ylog") are being set back to FALSE). Possible solutions: A. The code in par.c needs to be changed (possibly as I suggested earlier) to enable the proper restoration of par("usr") after log scaled axes are used OR B. If this is not possible due to causing other problems, par.Rd needs to have a warning note added to inform users that par("usr") will not be properly restored after log scales are used and that a possible solution would be to explicitly set par(xlog = FALSE) and par(ylog = FALSE) before restoring 'par' from saved values. This solution of course falls short if a function using this approach exits prematurely. One could include code in the on.exit() function to reset 'xlog' and 'ylog' before restoring 'par'. For example, using Jari's initial function plot2.log(): plot2.log <- function(x=1:2,y=1:2) { op <- par(no.readonly = TRUE) exit.restore <- function() { par(xlog =FALSE) par(ylog = FALSE) par(op) } on.exit(exit.restore()) plot(x, y, log = "y") } Again, my apologies if I am mis-reading the section from your reply above. Regards, Marc Schwartz -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._