Skip to content

Plotting Basics

Meghan Balk edited this page Mar 29, 2018 · 16 revisions

Plot

x <- c(1, 3, 1, 2, 5, 1)
y <- c(1:10)
 
plot(x)
plot(x, type =o”, col =green”)
title(main =Random Data”, col.main =blue”, font.main = 4)
lines(y, type =o”, col =red”)

Exercise:

  • Make the points triangles rather than circles.
  • Make the lines dashed.
  • Add a legend.
data(iris)
pairs(iris)

What is the output of this function?

Exercise:

  • What is the distribution of petal lengths? (hint: make a histogram)
  • What is the spread of petal lengths per species? (hint: use a box plot)