[R] behaviour of plot() when coord. are out of range

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Sep 23 14:20:19 CEST 2000



Marcus Eger wrote:
> 
> Dear all,
> 
> a question concerning the plot range. When I plot
> at first with linear coordinates, a subsequent polygon() call produces
> a figure that I expect. However, when I apply a logarithmic scale,
> two polygons appear. Is it possible to override this behaviour?
> 
>   M. Eger
> 
> Example:
> 
> y <- c(1.84147098480790, 1.90929742682568, 1.14112000805987,
> 0.243197504692072, -0.958924274663133,0.720584501801074,
> 1.65698659871879, 1.98935824662338, 1.41211848524176,0.45597888911063)
> 
> plot(y,ylim=c(0.0000000001,2),type="l")
> 
> plot(y,ylim=c(0.0000000001,2),type="l",log="y")
> Warning in xy.coords(x, y, xlabel, ylabel, log) :
>          1 y value <= 0 omitted from logarithmic plot
> 
> polygon(1:10,y,col="red")
> 

In your case, the fifth y value is ommitted, so polygone cannot work as
you are expecting.
The following should work:


 y <- c(1.84147098480790, 1.90929742682568, 1.14112000805987,
 0.243197504692072, -0.958924274663133,0.720584501801074,
 1.65698659871879, 1.98935824662338, 1.41211848524176,0.45597888911063)

 plot(y,ylim=c(0.0000000001,2),type="l",log="y")

 x <- 1:10
 temp <- which(y<0)
 polygon(x[-temp], y[-temp], col="red")


Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list