N <- 1000 x1 <- rnorm(N) x2 <- 1 + x1 + rnorm(N) quartz(height=4) plot(0) quartz(height=4) plot(0,1) quartz(height=4) plot(x1) # scatter plot x1 on the horizontal axis and x2 on the vertical axis quartz(height=4) plot(x1,x2) # the same but using a formula (x2 as a function of x1) quartz(height=4) plot(x2 ~ x1) # show all the available methods for plot (depending on the number of loaded packages). methods(plot) quartz(height=4) plot(x1,x2, main = "Main title", sub = "sub title" , ylab = "Y axis", xlab = "X axis") quartz(height=4) plot(x1,x2 , ylab = "Y axis", xlab = "X axis") title(main = "Main title", sub = "sub title" ) quartz(height=4) plot(x1, type = "l", col = 1, lty = 1) lines(x2, col = 2, lty = 2) legend("bottomleft", legend = c("x1","x2"), col = 1:2, lty = 1:2) quartz(height=4) plot(x1,x2, main = "Main title", sub = "sub title" , ylab = "Y axis", xlab = "X axis") quartz(height=4) plot(x1,x2 , ylab = "Y axis", xlab = "X axis") title(main = "Main title", sub = "sub title" ) quartz(height=4) plot(x1, type = "l", col = 1, lty = 1) lines(x2, col = 2, lty = 2) legend("bottomleft", legend = c("x1","x2"), col = 1:2, lty = 1:2) quartz(height=4) plot(x1, type = "l", col = 1, lty = 1) ; mtext("some text", side = 1) # the bottom quartz(height=4) plot(x1, type = "l", col = 1, lty = 1) ; mtext("some text", side = 2) # the left quartz(height=4) plot(x1, type = "l", col = 1, lty = 1) ; mtext("some text", side = 3) # the top quartz(height=4) plot(x1, type = "l", col = 1, lty = 1) ; mtext("some text", side = 4) # the right margin colors() # list the r colors quartz(height=4) plot(x1, type = "l", lty = "dotted") abline(h= -3, lty = "dashed", col = "gray") abline(v = 0, lty = "dashed", col = "gray") curve(x^2, from = -1 , to = 1, main = "Quadratic function", ylab = "f(x)=x^2") quartz(height=4) plot(rnorm(100)) curve((x/100)^2, add = TRUE, col = "red")