[R] How to plot two graphs on one single plot?
Yun Zhang
yunzhang at Princeton.EDU
Fri Feb 23 15:43:18 CET 2007
Hi,
I am trying to plot two distribution graph on one plot. But I dont know
how. I set them to the same x, y limit, even same x, y labels.
Code:
x1=rnorm(25, mean=0, sd=1)
y1=dnorm(x1, mean=0, sd=1)
x2=rnorm(25, mean=0, sd=1)
y2=dnorm(x2, mean=0, sd=1)
plot(x1, y1, type='p', xlim=range(x1,x2), ylim=range(y1, y2), xlab='x',
ylab='y')
plot(x2, y2, type='p', col="red", xlab='x', ylab='y')
They just dont show up in one plot.
Any hint will be very helpful.
Thanks,
Yun
More information about the R-help
mailing list