[Rd] buglet in curve?

Ben Bolker bolker at ufl.edu
Sun Dec 9 05:12:06 CET 2007


-----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-----



More information about the R-devel mailing list