I have a R script that contain these lines for plotting: plot(foo,lwd=2,lty=3,col="red", main=""); plot(bar,lwd=2,lty=3,col="blue"); legend(0.6,0.6,c('Default','Probabilistic'), col=c('red','blue'),lwd=3); But it generate 1 file (Rplot.pdf) with two pages. Each page for 1 plot. Is there a way I can put them together in to one page? - G.V.
Dear Jorge, Thanks for the reply. But what I mean is to create plot on "top" of another in to one page. So in the end there will be only one plot with two curves. Actually what I am to plot is two ROC curves. - G.V. On Tue, Feb 1, 2011 at 3:37 PM, Jorge Ivan Velez <jorgeivanvelez at gmail.com> wrote:> Hi Gundala, > Yes. > One way of doing it would be writing > par( mfrow = c(1, 2)) > before plotting your variables. Thus, the following should do it: > par( mfrow = c(1, 2)) ? ? # see ?par and the argument mfrow for more > information > plot(foo,lwd=2,lty=3,col="red", main=""); > plot(bar,lwd=2,lty=3,col="blue"); > legend(0.6,0.6,c('Default','Probabilistic'), col=c('red','blue'),lwd=3); > > A second option would be setting up a suitable layout. For this, please take > a look at ?layout. > Best, > Jorge > > > On Tue, Feb 1, 2011 at 12:20 AM, Gundala Viswanath <> wrote: >> >> I have a R script that contain these lines for plotting: >> >> plot(foo,lwd=2,lty=3,col="red", main=""); >> plot(bar,lwd=2,lty=3,col="blue"); >> legend(0.6,0.6,c('Default','Probabilistic'), col=c('red','blue'),lwd=3); >> >> >> But it generate 1 file (Rplot.pdf) with two pages. Each page for 1 plot. >> Is there a way I can put them together in to one page? >> >> - G.V. >> >> ______________________________________________ >> R-help at 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. > >
par(mfrow=c(3,2)) ## will get you 3 rows and 2 columns -- View this message in context: http://r.789695.n4.nabble.com/How-to-Plot-Two-Curves-Into-One-Page-tp3250546p3250567.html Sent from the R help mailing list archive at Nabble.com.
abline() or lines() -- View this message in context: http://r.789695.n4.nabble.com/How-to-Plot-Two-Curves-Into-One-Page-tp3250546p3250568.html Sent from the R help mailing list archive at Nabble.com.
On Tue, 1 Feb 2011 14:20:51 +0900 Gundala Viswanath <gundalav at gmail.com> wrote:> I have a R script that contain these lines for plotting: > > plot(foo,lwd=2,lty=3,col="red", main=""); > plot(bar,lwd=2,lty=3,col="blue"); > legend(0.6,0.6,c('Default','Probabilistic'), > col=c('red','blue'),lwd=3); > > > But it generate 1 file (Rplot.pdf) with two pages. Each page for 1 > plot. > Is there a way I can put them together in to one page? > > - G.V. >Hello Gundala, If these are fairly simple plots (i.e. curve, points, bar, step) you can arrange your data as columns in a matrix and use matplot(). matplot(vectorOfxValues, FooBarAsMatrix, lwd=2, lty=3, col=c("red", "blue")) legend(0.6,0.6,c('Default','Probabilistic'), col=c('red','blue'),lwd=3) Regards, Edwin -- Dr. Edwin Groot, postdoctoral associate AG Laux Institut fuer Biologie III Schaenzlestr. 1 79104 Freiburg, Deutschland +49 761-2032945