2.3 Faceting and Additional Options

Create a scatter plot of the diamonds dataset with z on the x axis and price on the y axis, and divide it into facets based on the diamond's cut

ggplot(diamonds, aes(x=z, y=price)) + geom_point() + facet_wrap(~ cut)


Create a scatter plot of the diamonds dataset with z on the x axis and price on the y axis, and divide it into a facetted grid. Let rows in the grid represent different cuts, and let each column represent a different color

ggplot(diamonds, aes(x=z, y=price)) + geom_point() + facet_grid(cut ~ color)


Create a scatter plot of the diamonds dataset with z on the x axis and price on the y axis. Give it a title of "My Graph", and limit the y axis from 0 to 10000.

ggplot(diamonds, aes(x=z, y=price)) + geom_point() + ggtitle("My Graph") + ylim(0, 10000)


Create a scatter plot of the Orange dataset (which you first saw in Quiz 1.2) with age on the x-axis and circumference on the y-axis, faceted into five sub-plots based on the tree being measured

ggplot(Orange, aes(x=age, y=circumference)) + geom_point() + facet_wrap(~ Tree)