水燕舞778 发表于 2016-10-30 21:52 
求:如何用左右不同坐标来画两组散点图,谢谢~
set.seed(2015)
n<-100
x1<-runif(n,1.4,5.7)
y1<-sin(x1)
#x2<-runif(n,1.2,6)
y2<-cos(x1)
plot(y1~x1,xlab="x",ylab="y",type="p",axes=F,pch=1)
axis(1)
axis(2)
par(new=T)
plot(y2~x1,xlim=c(1.2,6),axes=F,type="p",pch=2,xlab="",ylab="",main="Scatter Plot of Sin and Cos")
axis(4,col="red",col.axis="red")
legend("topright",legend=c("y1","y2"),pch=c(1,2))