Skip to content

buglet in curve?

2 messages · Ben Bolker, Martin Maechler

#
-----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-----
1 day later
#
BB> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1


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

    BB>  Credit goes to Mike McCoy for detecting the problem.

    BB>   Demonstration:

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


    BB>    I believe the problem arises from this fix:

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

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

   [    .....   ]

Thank you, Ben  (and Mike).
That's indeed a new buglet, and you are even right about
when it happened.
Mea culpa.

    BB>   cheers Ben Bolker

 {aaaah, it feels good to get a message from you without the
  appended Nabble spam :-)}

Regards,
Martin