[R] behaviour of plot() when coord. are out of range
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Sep 27 22:02:01 CEST 2000
Marcus Eger wrote:
> Yes it works... now only one polygon appears. However, in the linear
> plot (log="")
> the drawn lines are extrapolated until they reach the plot boundary,
> i.e. the polygon
> polygon(x, y, col="red") is clipped by the boundary.
> On the other hand, using log="" this extrapolation is not done because
> the negative
> value is omitted. I actually wished this value would not just be
> omitted.
> It could simply lie outside the range - and thus, there could be a
> vertical extrapolation
> line indicating it.
>
> The whole thing is important for me because I want to fill the area
> below the curve.
>
> Marcus Eger
Another quick hack in the evening (and looks ugly so far). Hope it
helps.
Uwe Ligges
y <- c(1.84147098480790, 1.90929742682568, 1.14112000805987,
0.243197504692072, -0.958924274663133,0.720584501801074,
1.65698659871879, 1.98935824662338, 1.41211848524176,0.45597888911063)
x <- 1:length(y)
plot(y,ylim=c(0.0000000001,2),type="l",log="y")
temp <- which(y < 0)
down <- 10^par("usr")[3]
## The next two lines will only work for one negative value,
## in other cases you will have to loop (?, no idea to vectorize it)
## over similar lines.
x2 <- x[c(1:(temp - 1), temp - 1, temp + 1, (temp + 1) : length(y))]
y2 <- c(y[1:(temp - 1)], down, down, y[(temp + 1) : length(y)])
polygon(x2, y2, col="red")
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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