Bharani Akella has an introduction to ggplot2:
Plot10: Scatter-plot
ggplot(data = mtcars,aes(x=mpg,y=hp,col=factor(cyl)))+geom_point()
-
mpg(miles/galloon) is assigned to the x-axis
-
hp(Horsepower) is assigned to the y-axis
-
factor(cyl) {Number of cylinders} determines the color
-
The geometry used is scatter plot. We can create a scatter plot by using the geom_point() function.
He has a number of similar examples showing several variations on bar, line, and scatterplot charts.