facet_grid {ggplot2}R Documentation

facet_grid

Description

Lay out panels in a rectangular/tabular manner.

Usage

facet_grid(facets=. ~ ., margins=FALSE, ...)

Arguments

facets a formula with the rows (of the tabular display) on the LHS and the columns (of the tabular display) on the RHS; the dot in the formula is used to indicate there should be no faceting on this dimension (either row or column); the formula can also be entered as a string instead of a classical formula object
margins logical value, should marginal rows and columns be displayed
... other arguments

Details

This page describes facet_grid, see layer and qplot for how to create a complete plot from individual components.

Value

A layer

Author(s)

Hadley Wickham, http://had.co.nz/

See Also

Examples

## Not run: 
# faceting 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 faceting specifications
# p + facet_grid("cut ~ .")

# see also ?plotmatrix for the scatterplot matrix

## End(Not run)

[Package ggplot2 version 0.7 Index]