[Rd] clipped lines have wrong slope in log plot (PR#839)

Emmanuel Paradis paradis@isem.univ-montp2.fr
Mon, 05 Feb 2001 12:12:29 +0100


At 02:17 05/02/01 +0100, you wrote:
>Hi,
>
>I'm using R version 1.2.0 (2000-12-15), on RedHat Linux 6.2 (kernel 2.2.14).
>
>The following command ought to plot a straight-line on a log-log
>graph but instead plots two line segments, both with the wrong
>slope:
>
>  plot(c(1,10,100),c(100,10,1),type="l",xlim=c(1,20),ylim=c(1,20),log="xy")
>
>Only clipped lines seem to have this problem.  Changing to type "b"
>or enlarging the ranges fixes it:
>
>  plot(c(1,10,100),c(100,10,1),type="b",xlim=c(1,20),ylim=c(1,20),log="xy")
>  plot(c(1,10,100),c(100,10,1),type="l",xlim=c(1,100),ylim=c(1,100),log="xy")
>
>abline has the same problem.  Try following the above calls with
abline(2,-1).
>(This is supposed to plot a straight line in the log-log domain, and
>does, but it's the wrong straight line.)
>
>I can also get the problem where only one axis is logarithmic.  
>Let's untransform the x-axis from the original command:
> 
>
plot(log(c(1,10,100)),c(100,10,1),type="l",xlim=log(c(1,20)),ylim=c(1,20),lo
g="y")
>
>Thanks! - Jason Eisner

I had a similar result with R-1.2.1 on WinNT 4.0.

plot(c(1,10,100), c(100,10,1), type="l", log="xy")  ### this looks OK
plot(c(1,10,100), c(100,10,1), type="l", xlim=c(1,20), ylim=c(1,20), log="xy")

I'd expect setting xlim= and ylim= would 'zoom in' on the first plot, but
it doesn't. It seems that, in this second case, that the coordinates of the
points outside the plotting region are not computed on the log-scale but on
the normal arithmetic scale.


Emmanuel Paradis
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._