[R] How to plot two dataset in one fig?

Francisco J. Zagmutt gerifalte28 at hotmail.com
Fri Nov 18 23:28:38 CET 2005


If I understand your question, to superimpose two lines in a same plot, in 
the first call to plot() you want to set the plot(ylim) argument with a 
range that will fit both of your lines.  Then use lines() to add the second 
lowess line on the plot.  Or matplot() will automate the process for you.

Take a look at savePlot() to save your final figure.


Francisco

>From: Wei Qiu <wqiu at nmr.mgh.harvard.edu>
>To: r-help at stat.math.ethz.ch
>Subject: [R] How to plot two dataset in one fig?
>Date: Fri, 18 Nov 2005 16:38:48 -0500 (EST)
>
>Hi all,
>
>I am new in R tool. I would like to plot two dataset in in fig.
>
>Here is what I did for both a and b data sets
>
>jpeg(file="a.jpeg")
>dat<-read.table('a', header=F, sep=',')
>dim(dat)
>y<-dat[,1]
>y<-y[!is.na(y)]
>plot(y);lines(lowess(y, f=0.05), col =
>("red"), lwd=5)
>dev.off
>
>Two questions:
>1. How I can save this lowess smooth data?
>2. Once I have the smooth a and b data, How I can put two smooth data sets
>in one fig even they have different Y ranger value?
>
>Any input will be greatly appreciated.
>
>Lucy
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! 
>http://www.R-project.org/posting-guide.html




More information about the R-help mailing list