### Techniques for plotting several curves and comparing the results. ## Generating some simulated data to illustrate the ideas n_500 x_sort(runif(n,0,10)) f1_sin(x) f2_1.2*sin(x) f3_1.1*sin(x/1.2) f4_1.2*sin(x/1.1) ## plotting 2 lines ... superposition works here # superposed plot(x, f3,type="l", ylab="y") lines(x, f1) title(main="Two Superposed Curves") # juxtaposed par(mfrow=c(2,1)) plot(x,f3, type="l", ylab="y") abline(v=c(0,2,4,6,8,10), h=c(-1, -.5, 0, .5, 1), lty=2) title(main="Two Juxtaposed Curves") plot(x,f3, type="n", ylab="y") lines(x,f1, type="l") abline(v=c(0,2,4,6,8,10), h=c(-1, -.5, 0, .5, 1), lty=2) ## plotting 4 lines par(mfrow=c(1,1)) # Superposed with different line types plot(x,f4,type="l") lines(x,f2,col=2) lines(x,f3,col=3) lines(x,f1,col=4) title(main="Four Superposed Curves", sub="Color Coded") # Superposed with no difference between lines plot(x,f4,type="l") lines(x,f2) lines(x,f3) lines(x,f1) title(main="Four Superposed Curves") # Juxtaposed par(mfrow=c(2,2)) plot(x,f4, type="l", ylab="y") abline(v=c(0,2,4,6,8,10), h=c(-1, -.5, 0, .5, 1), lty=2) title(main="Curve 1") plot(x,f4, type="n", ylab="y") lines(x,f2, type="l") abline(v=c(0,2,4,6,8,10), h=c(-1, -.5, 0, .5, 1), lty=2) title(main="Curve 2") plot(x,f4, type="n", ylab="y") lines(x,f3, type="l") abline(v=c(0,2,4,6,8,10), h=c(-1, -.5, 0, .5, 1), lty=2) title(main="Curve 3") plot(x,f4, type="n", ylab="y") lines(x,f1, type="l") abline(v=c(0,2,4,6,8,10), h=c(-1, -.5, 0, .5, 1), lty=2) title(main="Curve 4")