# ------------------------------------------------------------------ # File name: plot_options.R # # plot() is a high-level R function that opens a new plotting window # Here, we will show some basic options to plot() with a sequence of plots # of square root function with increasing complexity # Type ?plot to see details of basic options; you can see # 657 available colores by typing colors() # # Version: 2.1 # Authors: H. Kocak, University of Miami and B. Koc, Stetson University # References: # https://www.r-project.org # ------------------------------------------------------------------ x = seq(from = 0, to = 10, by = 0.5) square_root_x = sqrt(x) # Plot x-values vs. square_root_x values with default options plot(x, square_root_x) # To pause between plots par(ask = TRUE) # To add title plot(x, square_root_x, main = "My First Plot") # To add label to y-axis plot(x, square_root_x, main = "My First Plot", ylab = "sqrt(x)") # To set limits of y-axis plot(x, square_root_x, main = "My First Plot", ylab = "sqrt(x)", ylim = c(0, 10)) # To add color plot(x, square_root_x, main = "My First Plot", ylab = "sqrt(x)", ylim = c(0, 10), col = "blue") # To over strike with both plotting characters, pch, and connecting lines plot(x, square_root_x, main = "My First Plot", ylab = "sqrt(x)", ylim = c(0, 10), col = "blue", type = "o") # To set the line type plot(x, square_root_x, main = "My First Plot", ylab = "sqrt(x)", ylim = c(0, 10), col = "blue", type = "o", lty = "dotted") # To set plotting character plot(x, square_root_x, main = "My First Plot", ylab = "sqrt(x)", ylim = c(0, 10), col = "blue", type = "o", lty = "dotted", pch = 22)