[R] Problems with segments and multiple graphs

Ross Darnell r.darnell at shrs.uq.edu.au
Thu Dec 5 05:47:03 CET 2002


I would like to create a page of two graphs (2 rows by 1 col) and then
draw vertical lines (segments?) on both graphs from the minimum
values to the corresponding maximum value.

So I have tried

#
> y <- rnorm(3000)
> par(mfrow=c(2,1))
> plot(y,type="l")
> plot(cumsum(y),type="l")
> segments(1000,min(cumsum(y)),1000,max(cumsum(y)))
> par(mfg=c(1,1))
> segments(1000,min(y),1000,max(y))
> y <- rnorm(3000)


The segment looks fine on the bottom graph but I get a small vertical
line on the top graph. The max(y) value looks OK but the min(y) looks
like the second largest value.

> ymin <- min(y)
> ymax <- max(y)
> segments(1000,ymin,1000,ymax)

doesn't make any difference.

Can I draw a (one) line that crosses both graphs?

Thanks 

Ross Darnell
-- 
Ross Darnell
Email: <r.darnell at shrs.uq.edu.au>




More information about the R-help mailing list