gghistogram: Grob function: histogram

Description Usage Arguments Details Examples

View source: R/grobs-complex.r

Description

Conceptually, the histogram is one of the most complicated of the grob functions, becuase it takes a 1D data set and makes it two dimensional. This necessitates an extra step, the pre_histogram function which bins the data and returns the bins with their counts. This data is then used my grob_histogram to plot the points.

Usage

1
2
gghistogram(plot, aesthetics = list(), scale = "prob", ...,
  data = NULL)

Arguments

plot

the plot object to modify

aesthetics

named list of aesthetic mappings, see details for more information

scale

scale of y-axis

...

other options, see details for more information

data

data source, if not specified the plot default will be used

Details

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:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(ggplot2movies)
m <- ggplot(movies, aesthetics=list(x=rating))
gghistogram(m)
gghistogram(m, breaks=100)

m <- ggplot(movies, Action ~ Comedy, aesthetics=list(x=rating), margins=TRUE)
gghistogram(m)
gghistogram(m, scale="freq")
gghistogram(m, colour="darkgreen", fill="white")
ggdensity(gghistogram(m, colour="darkgreen", fill="white"))

hadley/ggplot1 documentation built on Aug. 19, 2019, 2:42 p.m.