[R] How to Plot Two Curves Into One Page

Edwin Groot edwin.groot at biologie.uni-freiburg.de
Wed Feb 2 10:39:43 CET 2011


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



More information about the R-help mailing list