This problem has been an opportunity for me to learn about issues mixing base graphics with lattice plots. From the many pdfs and blogs and other things I have found, it seems that I have two options: 1) insert a viewport of my bar graph into a basic environment; or 2) do all of my plots in lattice.
I have tried each and have encountered difficulties. I think the simplest approach should be to add a lattice bar graph to the rest of my plot, because all of the plots are already made. Unfortunately, despite the many references to these issues, I was not able to find an example of this being done. I think it should involve I have most of the parts working, but am not sure how to put the last pieces together: nf <- layout(matrix(c(1,1,1,1,0,0,2,2,2,2,0,0,3,3,3,3,0,0,4,4,4,4,0,0,5,5,5,5,0,0),5,6, byrow=TRUE), respect=FALSE) # first my regular plots attach(mydatafile1) par(mar=c(0.2,4.5,0.2,0.5)) plot(xvalue, yvalue, frame=T) detach(mydatafile1) attach(mydatafile2) par(mar=c(0.2,4.5,0.2,0.5)) plot(xvalue, yvalue, frame=T) detach(mydatafile2) # now the bar plot in lattice, which I know will plot fine in its own window require(lattice) tmpdf <- data.frame(Time=rep(tmp$Time, 3), stack(tmp[,2:4])) barchart(values ~ Time, group=ind, data=tmpdf, stack=TRUE, horizontal=FALSE) plot5 <- xyplot(values ~ Time, group=ind, data=tmpdf, stack=TRUE, horizontal=FALSE, panel=panel.barchart) # here is the issue, how to get this into basic. I think I need a pushViewport command of some kind lviewport(x=unit(1, "npc") - unit(1, "inches"), y=0.5, width=0.2, height=0.5, just=c("right", "centre"))) print(plot3, position=c(0.01, 0, 1, 0.5)) Any thoughts about how to put the last pieces together would be very much appreciated. Marcel -- View this message in context: http://r.789695.n4.nabble.com/Plot-command-overwrites-existing-plot-in-multiple-figure-plot-tp3661245p3665545.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.