[R] Plot command overwrites existing plot in multiple figure plot

marcel marcelcurlin at gmail.com
Tue Jul 12 03:24:17 CEST 2011


Hi all,
I have a figure with 5 separate graphs in a stacked layout. While most of my
plots drop into their appointed spots nicely, my last plot, using lattice
and the plot(object) command insists on wiping out my current plot window
altogether, and just plotting the last figure by itself. The relevant part
of my code is of the form:

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 plot, plots well
attach(data1)
par(mar=c(0.2,4.5,0.2,0.5))
plot(var1, var2, frame=T, etc..) 
detach(data1)

#second plot, plots fine
attach(data2)
par(mar=c(0.2,4.5,0.2,0.5))
plot(var3, var4, frame=T, etc...) 
detach(data1)

require(lattice)
tmpdf <- data.frame(Mydata)
tmpdf                               #data show up fine
barchart(values ~ Time, group=ind, data=tmpdf, stack=TRUE, horizontal=FALSE)
xyplot(values ~ Time, group=ind, data=tmpdf, stack=TRUE, horizontal=FALSE,
panel=panel.barchart, ylim=c(-0.05,1.05), xlim=c(0,6))

# Problem here. This command will wipe out my existing window (prints
briefly and is then quickly replaced by the plot below
print(xyplot(values ~ Time, group=ind, data=tmpdf, stack=TRUE,
horizontal=FALSE, panel=panel.barchart, ylim=c(-0.05,1.05), xlim=c(0,6)))

Is there any way around this problem?

Marcel


--
View this message in context: http://r.789695.n4.nabble.com/Plot-command-overwrites-existing-plot-in-multiple-figure-plot-tp3661245p3661245.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list