From: Gabor Grothendieck <ggrothendieck_at_gmail.com>

Date: Tue 31 May 2005 - 13:19:09 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 31 13:23:33 2005

Date: Tue 31 May 2005 - 13:19:09 EST

I have also tried to use baseViewports with this but did not have any success.

How do I modify this example so that the horizontal red lines come out at the appropriate levels? Note that this is just an example and in the future I will want to have multiple viewports each with a base plot and add arbitrary additional line or point plots to them so the solution needs to be sufficiently general that I can so generalize it.

Thanks.

library(gridBase)

opar <- par(no.readonly = TRUE)

grid.newpage()

# two columns, one row

unit. <- unit(c(1,1), c("null","null"))

pushViewport(viewport(layout = grid.layout(1, 2, widths = unit.)))

# draw green graph in first column (viewport A)

pushViewport(viewport(layout.pos.col = 1, name = "A"))
par(fig = gridFIG()); par(new = TRUE)

plot(1:10, col = "green", pch = 20)

upViewport(1)

# draw purple graph in second column (viewport B)

pushViewport(viewport(layout.pos.col = 2, name = "B"))
par(fig = gridFIG()); par(new = TRUE)

plot(1:100, col = "purple", pch = 18)

upViewport()

# go back to A and add horizontal grid lines

seekViewport("A")

par(fig = gridFIG())

abline(h=1:10, col = "red") #### THESE DO NOT GET DRAWN AS EXPECTED
popViewport()

# go back to B and add vertical grid lines

seekViewport("B")

par(fig = gridFIG())

abline(v=1:10, col = "red")

popViewport()

par(opar)

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 31 13:23:33 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:32:16 EST
*