ggbar {ggplot}R Documentation

Grob function: bars

Description

Add bars to a plot

Usage

ggbar(plot = .PLOT, aesthetics=list(), ..., data=NULL)

Arguments

plot the plot object to modify
aesthetics named list of aesthetic mappings, see details for more information
... other options, see details for more information
data data source, if not specified the plot default will be used

Details

The bar grob produces bars from the y-position to the y=0.

Aesthetic mappings that this grob function understands:

These can be specified in the plot defaults (see ggplot) or in the aesthetics argument. If you want to modify the position of the points or any axis options, you will need to add a position scale to the plot. These functions start with ps, eg. pscontinuous or pscategorical

Other options:

Author(s)

Hadley Wickham <h.wickham@gmail.com>

See Also

ggrect

Examples

cyltab <- as.data.frame(table(cyl=mtcars$cyl))
p <- ggplot(cyltab, aes=list(y=Freq, x=cyl))
ggbar(p)
ggbar(p, fill="white", colour="red")
#Can also make a stacked bar chart
p <- ggplot(mtcars, aes=list(y=1, x=factor(cyl)))
ggbar(p, avoid="stack")
ggbar(p, avoid="stack", colour="red") # Made up of multiple small bars
p <- ggplot(mtcars, aes=list(y=mpg, x=factor(cyl)))
ggbar(p, avoid="stack")
ggbar(p, avoid="dodge", sort=TRUE)
ggbar(p, aes=list(fill=mpg), avoid="dodge", sort=TRUE)
ggbar(p, avoid="stack", sort=TRUE)

[Package ggplot version 0.4.2 Index]