liujb wrote:
Dear R users,
I need to compare two scatter plots,
plot(x1, y1)
plot(x2, y2)
and would like to plot them in the same figure. How do I do it?
Hi liujb,
How about this:
plot(x1,y1,xlim=range(c(x1,x2)),ylim=range(c(y1,y2)),col=red)
points(x2,y2,col=blue)
Jim
lattice and ggplot2 also offer a general way of doing this,
# first create a data.frame in the long format containing the two
data sets
x1 - seq(-10, 10)
x2 - seq(-8, 12)
y1 - sin(x1/3)
y2 - cos(x2/2)
d1 - data.frame(x=x1, y=y1, var=1)
d2 - data.frame(x=x2, y=y2, var=2)
library(reshape)
d -
Dear R users,
I need to compare two scatter plots,
plot(x1, y1)
plot(x2, y2)
and would like to plot them in the same figure. How do I do it?
Thank you.
--
View this message in context:
http://www.nabble.com/two-scatter-plots-in-one-tp21963375p21963375.html
Sent from the R help mailing list
Set the xlim/ylim to the extent of the data and then do
plot(x1, y1, xlim=range(x1, x2), ylim=range(y1, y2))
points(x2, y2, col='red')
On Wed, Feb 11, 2009 at 3:43 PM, liujb liujul...@yahoo.com wrote:
Dear R users,
I need to compare two scatter plots,
plot(x1, y1)
plot(x2, y2)
and would
4 matches
Mail list logo