[R] multiple plots in same graph window

William Dunlap wdunlap at tibco.com
Tue Apr 21 22:19:17 CEST 2009


If you call
   par(new=TRUE)
after each call to par(fig=c(xmin,xmax,ymin,ymax))
then a subsequent call to plot() will not erase
the page.

In S+ the par(new=TRUE) is not needed, but it does
no harm.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 

-------------------------------------------------
Hi,

I'm trying to make multiple plots in a same graph window in R. 

The multiple graphs are showing up in the right positions on the window,
but I'm having the problem that the graphic window is being refreshed
every time a new plot is drawn, so that I end up with only the last
graph coming up; the previous ones are all erased

If I try to print in a .eps file directly, then I end up with the first
plot only, in the right position of the page, and the others are not
plotted at all. 

The script I wrote is the following:

X11()

par(fig=c(0., 0.55, 0.45, 1.), cex=0.8)
plot(ldtime, dx[which(dphotons$energy<0.3, arr.ind=T)], type="l",
main="", xlab="seconds", ylab="cell density", xlim=c(min(hdtime),
max(ldtime)))

dev.set(dev.cur())
par(fig=c(0., 0.55, 0., 0.55),cex=0.8)
plot(hdtime, dx[which(dphotons$energy>0.5, arr.ind=T)], type="l",
xlab="seconds", ylab="cell density", xlim=c(min(hdtime), max(ldtime)))

dev.set(dev.cur())
par(fig=c(0.5, 1., 0., 1.), cex=0.8)
plot(x, cumsum(Pl)/max(cumsum(Pl)), type="l", main="", xlab="",
ylab="profile cumulative probability", xlim=c(min(hdtime), max(ldtime)))
points(x, cumsum(Ph)/max(cumsum(Ph)), type="l", col=gray(0.5))


Can someone please point me what I'm doing wrong?

thanks,
ulisses.




More information about the R-help mailing list