- x=0:10
- set.seed(1);y1=cumsum(rnorm(11))
- set.seed(2);y2=cumsum(rnorm(11,mean = 0.5))
- set.seed(3);y3=cumsum(rnorm(11,mean = -0.5))
- y=c(y1,y2,y3)
- plot(1, type = 'n', axes=FALSE, frame=TRUE,
- xlim = c(0,10),ylim = c(min(y),max(y)),
- xlab = 'x',ylab = 'y')
- lines(x,y1,col=1,lwd=2)
- lines(x,y2,col=2,lwd=2)
- lines(x,y3,col=3,lwd=2)
- legend('topleft',paste0('y',1:3),lwd=2,lty=1,bty = 'n',col = 1:3)
- axis(1, 0:10)
- tck1= round((max(y)-min(y))/10*0:10+min(y),1)
- axis(2, tck1, tck=-0.04,lwd.ticks = 2,cex.axis=0.75)
- tck2= rep((max(y)-min(y))/10/5*1:4,10)+
- rep((max(y)-min(y))/10*0:9+min(y),rep(4,10))
- axis(2, tck2, labels=rep("", length(tck2)), tck=-0.02)
复制代码
|