rAmCharts - amHist

Parameters

  • x: a vector of values for which the histogram is desired.
  • col: a colour to be used to fill the bars.
  • border: a colour for the borders.
  • 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).
  • labels: logical or character. Additionally draw labels on top of bars, if not FALSE; if TRUE, draw the counts or rounded densities; if labels is a character, draw itself.
  • xlab, ylab: character, labels of the axis.
  • ylim: the range of y values with sensible defaults.
  • control_hist: (optional) named list containing parameters for computing the histogram.
  • : other parameters called in amOptions.

Data used in the examples:

data_hist <- get(x = "iris", pos = "package:datasets")$Sepal.Length
head(data_hist)
## [1] 5.1 4.9 4.7 4.6 5.0 5.4

Reference example

amHist(x = data_hist)

Filling color

amHist(x = data_hist, col = "#CECECE")

Border color

amHist(x = data_hist, border = "#CECECE")

View density

amHist(x = data_hist, freq = FALSE)

Naming axis

amHist(x = data_hist, xlab = "xlab", ylab = "ylab")

Display values

amHist(x = data_hist, labels = TRUE)

Set ylim

amHist(x = data_hist, ylim = c(0,.8), freq = FALSE)

amOptions

export

amHist(x = data_hist, export = TRUE)
#or
amHist(x = data_hist) %>>% 
  amOptions(export = TRUE)

exportFormat

amHist(x = data_hist, export = TRUE, exportFormat = "JPG")
#or
amHist(x = data_hist) %>>% 
  amOptions(export = TRUE, exportFormat = "JPG")

main and creditsPosition

amHist(x = data_hist, main = "My Histogram",
        mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")
#or
amHist(x = data_hist) %>>% 
  amOptions( main = "My Histogram",
        mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")

theme

amHist(x = data_hist, theme = "patterns")
#or
amHist(x = data_hist) %>>% 
  amOptions(theme = "patterns")