plot_histogram: Plot histogram

Description Usage Arguments

View source: R/plot_histogram.R

Description

plot_histogram plots one or more histograms on a single panel

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
plot_histogram(
  x,
  freq = TRUE,
  breaks = "Sturges",
  y_buffer = 0.05,
  ylim = NULL,
  xlim = NULL,
  main = "",
  col = "lightgrey",
  bty = "o",
  add = FALSE,
  ...
)

Arguments

x

a list of entries to transform to a histogram and plot, or a matrix where each column is plotted as a histogram

freq

logical; if TRUE, the histogram graphic is a representation of frequencies, the counts component of the result; if FALSE, probability densities, component density, are plotted (so that the histogram has a total area of one). Defaults to TRUE if and only if breaks are equidistant (and probability is not specified).

breaks

one of:

  • a vector giving the breakpoints between histogram cells,

  • a function to compute the vector of breakpoints,

  • a single number giving the number of cells for the histogram,

  • a character string naming an algorithm to compute the number of cells (see ‘Details’),

  • a function to compute the number of cells.

In the last three cases the number is a suggestion only; as the breakpoints will be set to pretty values, the number is limited to 1e6 (with a warning if it was larger). If breaks is a function, the x vector is supplied to it as the only argument (and the number of breaks is only limited by the amount of available memory).

y_buffer,

a buffer at the top of the highest histogram

ylim,

bounds for y-axis (default is detected from x)

xlim,

bounds for x-axis (default is detected from x)

main

main title and axis labels: these arguments to title() get “smart” defaults here, e.g., the default ylab is "Frequency" iff freq is true.

col

a colour to be used to fill the bars. The default of NULL yields unfilled bars.

...

arguments passed to hist


James-Thorson/utilities documentation built on Feb. 6, 2022, 2:35 p.m.