Thursday, October 20, 2011
Making basic plots with qplot( ) in the ggplot2 package
The package qqplot2 offers a lot of improvements over the basic plot() function in R. The basic syntax is luckily not that different than plot().
A qplot statement looks like this:
qplot(xaxis, yaxis, data = dataframe, geom = "point", color = category, xlab = "label", ylab = "label", main = "title")
So, a plot statement could look like
qplot(mass, offspring, data = reproduction, geom = "point", color = plot)
geom can take on several things:
geom = "line"
geom = c("point", "smooth") => a scatter plot with a smoothing spline
geom ="histogram" => standard histogram
geom = "density" => a smooth distribution curve instead of a histogram
Graphs with multiple panels are created by including "facets = "
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment