gghistogram: Histogram with optional normal and kernel density functions

View source: R/ggplot.R

gghistogramR Documentation

Histogram with optional normal and kernel density functions

Description

Plots a histogram and density estimates using ggplot.

Usage

gghistogram(
  x,
  add.normal = FALSE,
  add.kde = FALSE,
  add.rug = TRUE,
  bins,
  boundary = 0
)

Arguments

x

a numerical vector.

add.normal

Add a normal density function for comparison

add.kde

Add a kernel density estimate for comparison

add.rug

Add a rug plot on the horizontal axis

bins

The number of bins to use for the histogram. Selected by default using the Friedman-Diaconis rule given by grDevices::nclass.FD()

boundary

A boundary between two bins.

Value

None.

Author(s)

Rob J Hyndman

See Also

graphics::hist(), ggplot2::geom_histogram()

Examples


gghistogram(lynx, add.kde = TRUE)


forecast documentation built on March 18, 2026, 9:07 a.m.