# Scatter Plot Tutorial attach(iris) # Plot Petal length with regards to width plot(Petal.Length, Petal.Width, pch = 16, col = ifelse(Species == "setosa", "red", ifelse(Species == "virginica", "yellow", "blue")), xlab = "P Lenth", ylab = "P Width", main = "TITLE") # Add regression line abline(lm(Petal.Width ~ Petal.Length), col = "red") #Add Legend to plot legend(1, max(Petal.Width), c("Setosa", "Virginica", "Versicolor"), col = c("red", "blue", "yellow"), pch = 16) #Add text to plot text(4, 2.5, "Useful Text") text(locator(3), c("Setosa", "Virginica", "Versicolor"), col = c("red", "blue", "black")) detach(iris)