facet_grid {ggplot2} | R Documentation |
Lay out panels in a rectangular/tabular manner.
facet_grid(facets=. ~ ., margins=FALSE, ...)
facets |
NULL |
margins |
NULL |
... |
ignored |
This page describes facet_grid, see layer
and qplot
for how to create a complete plot from individual components.
A layer
Hadley Wickham, http://had.co.nz/
## Not run: # Facetting displays subsets of the data in different panels p <- ggplot(diamonds, aes(x=carat, y=..density..)) + geom_histogram(binwidth=0.2) # With one variable p + facet_grid(. ~ cut) p + facet_grid(cut ~ .) # With two variables p + facet_grid(clarity ~ cut) p + facet_grid(cut ~ clarity) p + facet_grid(cut ~ clarity, margins=TRUE) # You can also use strings, which makes it a little easier # when writing functions that generate facetting specifications # p + facet_grid("cut ~ .") # see also ?plotmatrix for the scatterplot matrix ## End(Not run)