From bolker at ufl.edu  Sun Dec  9 05:12:06 2007
From: bolker at ufl.edu (Ben Bolker)
Date: Sat, 08 Dec 2007 23:12:06 -0500
Subject: [Rd] buglet in curve?
Message-ID: <475B6B16.6040909@ufl.edu>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


  Symptoms: curve with log x axis gets the wrong
x limits (in 2.6.1, I believe introduced in this version).

 Credit goes to Mike McCoy for detecting the problem.

  Demonstration:

x = 1:5
plot(x,5*exp(-x),xlim=c(0.1,1000),log="x")
xvec = 10^seq(-1,3,length=100)
lines(xvec,5*exp(-xvec))
curve(5*exp(-x),add=TRUE,col=2,lwd=3)


   I believe the problem arises from this fix:

    o	curve() with unspecified 'from', 'to' and 'xlim' now reuses the
	previous x limits, and not slightly larger ones.

 and I believe the solution is to replace this ...

   if (is.null(xlim))
        delayedAssign("lims", {
            pu <- par("usr")[1:2]
            ll <- if (par("xlog"))
                10^pu
            else pu
            if (par("xaxs") == "r")
                extendrange(ll, f = -1/27)
            else ll
        })


 with this ...

   if (is.null(xlim))
        delayedAssign("lims", {
            pu <- par("usr")[1:2]
             if (par("xaxs") == "r")
                pu <- extendrange(pu, f = -1/27)
            ll <- if (par("xlog"))
                10^pu
            else pu
            ll
        })

  i.e., extend pu, not ll ...

  cheers
    Ben Bolker







-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHW2sWc5UpGjwzenMRApDiAJ9VNtfvdFBbFQvF6Nt5BrgkvcsunACfZFeg
eHBtIBAxrRvj1LpRkT6wdgo=
=ZFiA
-----END PGP SIGNATURE-----



[Rd] buglet in curve?
Ben Bolker