Friday, August 3, 2012

How to make simple scatter plots in R

How to make a simple scatter plot in R:

For example we will create two variables and plot them in a scatter plot.
a <- c(1:100)
b <- rnorm(100, 5, 0.5)


plot(a,b)



If we want to make a line instead of dots:
plot(a,b, type="l")





To change the title, axis labels, and color of the line type the following:
plot(a,b, type="l",main="Title of the graph", xlab="x axis label", ylab="y axis label", col=634)
For the list of colors type:
colors()





No comments:

Post a Comment