Hi Pat,
Certainly you can
But you need to provide more details, will advise closely
In general, first you plot the “frame” without plotting like this


plot(range(data1$x1,data2$x2), range(data1$y1,data2$y2), type=’n’) # means
just plotting a frame with xaxis ranges from x1-x2 and y from y1-y2, but no
plotting

then depends on your data type (i.e. line or scatter or blah blah) then you
have specific command for them
Give you here an example for reference:

# Two scatter plots in the same graph:

data1 <- data.frame(x1=rnorm(100,70,7), y1=rnorm(100,35,5))
data2 <- data.frame(x2=rnorm(100,78,8),  y2=rnorm(100,40,5))
plot(range(data1$x1,data2$x2), range(data1$y1,data2$y2), type=’n’) 
points(data1$x1,data1$y1,pch=17, col=’blue’)
points(data2$x2,data2$y2,pch=16, col=’red’)


Cheers
Nguyen

Message: 82
Date: Tue, 8 May 2007 16:49:47 -0700 (PDT)
From: "Patrick Wang" <[EMAIL PROTECTED]>
Subject: [R] draw two plots on a single panel
To: [email protected]
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain;charset=iso-8859-1

Hi,

I have 2 dataset,

plot(data1)
plot(data2),

but it comes as two graphs, can I draw both on a single panel so I can
compare them?

Thanks
Pat

______________________________________________
[email protected] 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.

Reply via email to