Skip to contents

Producing Histograms

Usage

plotHistogram(
  data = NULL,
  metaData = NULL,
  x = NULL,
  dataMapping = NULL,
  bins = NULL,
  binwidth = NULL,
  stack = NULL,
  distribution = NULL,
  plotConfiguration = NULL,
  plotObject = NULL
)

Arguments

data

A data.frame to use for plot.

metaData

A named list of information about data such as the dimension and unit of its variables.

x

Numeric values to plot along the x axis. Only used instead of data if data is NULL.

dataMapping

A HistogramDataMapping object mapping x and aesthetic groups to their variable names of data.

bins

Number or edges of bins. If bins is provided as a single numeric values, bin corresponds to number of bins. The bin edges are then equally spaced within the range of data. If bins is provided as an array of numeric values, bin corresponds to their edges.

binwidth

Numerical value of defining the width of each bin. If defined, binwidth can overwrite bins if bins was not provided or simply provided as a single value.

stack

Logical defining for multiple histograms if their bars are stacked

distribution

Name of distribution to fit to the data. Only 2 distributions are currently available: "normal" and "logNormal"

plotConfiguration

An optional HistogramPlotConfiguration object defining labels, grid, background and watermark.

plotObject

An optional ggplot object on which to add the plot layer

Value

A ggplot object

Examples

# Produce histogram of normally distributed data
plotHistogram(x = rnorm(100))


# Produce histogram of normally distributed data with many bins
plotHistogram(x = rlnorm(100), bins = 21)


# Produce histogram of fitted normally distributed data
plotHistogram(x = rlnorm(100), distribution = "normal")