Wandering usr values in par(no.readonly=TRUE) (PR#2283)

Marc Schwartz mschwartz@medanalytics.com
Wed, 13 Nov 2002 17:06:00 -0600

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.


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


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)


  plot(x, y, log = "y")

Again, my apologies if I am mis-reading the section from your reply


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