Learn R Programming

tidyplots (version 0.2.2)

add_histogram: Add histogram

Description

Add histogram

Usage

add_histogram(plot, binwidth = NULL, bins = NULL, ...)

Value

A tidyplot object.

Arguments

plot

A tidyplot generated with the function tidyplot().

binwidth

The width of the bins. Can be specified as a numeric value or as a function that takes x after scale transformation as input and returns a single numeric value. When specifying a function along with a grouping structure, the function will be called once per group. The default is to use the number of bins in bins, covering the range of the data. You should always override this value, exploring multiple widths to find the best to illustrate the stories in your data.

The bin width of a date variable is the number of days in each time; the bin width of a time variable is the number of seconds.

bins

Number of bins. Overridden by binwidth. Defaults to 30.

...

Arguments passed on to the geom function.

Examples

Run this code
energy |>
  tidyplot(x = energy) |>
  add_histogram()

energy |>
  tidyplot(x = energy, color = energy_type) |>
  add_histogram()

Run the code above in your browser using DataLab