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. [[alternative HTML version deleted]]
On Apr 21, 2009, at 12:58 PM, BARRES-DE-ALMEIDA U. wrote:> 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?Either use layout or par(mfcol=2, mfrow=2) Modified from the example in layout's help: layout(matrix(c(1,2,3,4), 2, 2, byrow = TRUE)) ## show the regions that have been allocated to each plot layout.show(4)>David Winsemius, MD Heritage Laboratories West Hartford, CT
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.