Hi I would like to be able to add reference lines to a series of plots that are built using the Grid graphics package. These lines should coincide with tick marks which are different on each plot.
I can add the lines manually using the grid.lines() function but would like to understand how to generate them on the fly. Any help would be gratefully received. Kind regards Pete ####################################################################### # FUNCTION MYPLOT ####################################################################### myplot=function(i,j){ pushViewport(viewport(layout.pos.col=i,layout.pos.row=j)) pushViewport(plotViewport(c(3,2,2,3))) x <- runif(10) y <- (i+j)*runif(10) pushViewport(dataViewport(range(x),pretty(y),name="plotRegion")) grid.points(x, y) grid.rect() grid.xaxis() grid.yaxis(main=FALSE) # How can I use grid.lines to create reference lines at the tick marks for each graph? # grid.lines(x=0:1,y=0.2) grid.text(paste("Plot ",i," ",j,sep=""), y = unit(1, "npc") + unit(0.5, "lines"), gp = gpar(fontsize = 16)) popViewport() popViewport(2) } ####################################################################### # END FUNCTION MYPLOT ####################################################################### grid.newpage() grid.rect(gp=gpar(fill="white")) pushViewport(viewport(layout=grid.layout(2, 2))) myplot(1,1) myplot(1,2) myplot(2,1) myplot(2,2) popViewport() -- View this message in context: http://r.789695.n4.nabble.com/Reference-Lines-Using-Grid-Graphics-tp3349185p3349185.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.