histogram: Histogram of Marginal Densities

View source: R/eratosthenes.R

histogramR Documentation

Histogram of Marginal Densities

Description

Wrapper around hist to plot density histograms for select marginal densities (up to 12) in a single plot, from the results of gibbs_ad, or to plot density histograms of the production, deposition, and use of a type, from the results of gibbs_ad_use].

Usage

histogram(
  x,
  events = NULL,
  aspect = c("production", "use", "deposition"),
  display_name = "Type",
  breaks = "Freedman-Diaconis",
  xlim = NULL,
  ylim = NULL,
  xlab = "Year",
  palette = NULL,
  opacity = 1,
  legend_pos = "topright"
)

## S3 method for class 'marginals'
histogram(
  x,
  events = NULL,
  aspect = NULL,
  display_name = NULL,
  breaks = "Freedman-Diaconis",
  xlim = NULL,
  ylim = NULL,
  xlab = "Year",
  palette = NULL,
  opacity = 1,
  legend_pos = "topright"
)

## S3 method for class 'use_marginals'
histogram(
  x,
  events = NULL,
  aspect = c("production", "use", "deposition"),
  display_name = "Type",
  breaks = "Freedman-Diaconis",
  xlim = NULL,
  ylim = NULL,
  xlab = "Year",
  palette = NULL,
  opacity = 0.5,
  legend_pos = "topright"
)

Arguments

x

A list object of class marginals, the output of gibbs_ad, or of class use_marginals, to plot the output of gibbs_ad_use].

events

If plotting a marginals object, a vector or element of the event names to plot. Maximum number of events is 12.

aspect

If plotting a use_marginals object, that is, the output of gibbs_ad_use, a vector of one or more of c("production", "use", "deposition"). The default is all three.

display_name

If plotting a use_marginals object, the name of the artifact type to display in the histogram legend. Default is "Type".

breaks

The number or method of breaks in the histogram. Default is "Freedman-Diaconis". See hist for more.

xlim

The limits of the x-axis. Default is set to the min/max values of all samples.

ylim

The limits of the y-axis. This may need to be adjusted if densities have an extremely narrow interval.

xlab

Label for the x-axis. Default is "Year".

palette

A vector providing the color palette of the histogram. The default is "colorBlindness::paletteMartin" (see palettes_d).

opacity

The opacity/transparency of the histograms for visualizing overlapping events, a value between 0 and 1 (default).

legend_pos

The position of the legend in the plot. Default is "topright".

Details

Also see also tidy_marginals for exporting the results of these functions into tidy data frame for custom plotting in e.g., ggplot2.

Value

A density histogram of the selected events/aspects.

A density histogram of the selected events/aspect.

Examples

x <- c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
y <- c("B", "D", "G", "H", "K")
z <- c("F", "K", "L", "M")
contexts <- list(x, y, z)

f1 <- list(id = "find01", assoc = "D", type = c("type1", "form1"))
f2 <- list(id = "find02", assoc = "E", type = c("type1", "form2"))
f3 <- list(id = "find03", assoc = "G", type = c("type1", "form1"))
f4 <- list(id = "find04", assoc = "H", type = c("type2", "form1"))
f5 <- list(id = "find05", assoc = "I", type = "type2")
f6 <- list(id = "find06", assoc = "H", type = NULL)

artifacts <- list(f1, f2, f3, f4, f5, f6)
 
# external constraints
coin1 <- list(id = "coin1", assoc = "B", type = NULL, samples = runif(100,-320,-300))
coin2 <- list(id = "coin2", assoc = "G", type = NULL, samples = seq(37, 41, length = 100))
destr <- list(id = "destr", assoc = "J", type = NULL, samples = 79)

tpq_info <- list(coin1, coin2)
taq_info <- list(destr)

result <- gibbs_ad(contexts, finds = artifacts, tpq = tpq_info, taq = taq_info)

# deposition of "B"
histogram(result, "B")

# deposition of "coin2" and deposition of "G"
histogram(result, c("coin2", "G"), opacity = 0.5)

# production of "type2" and deposition of "H"
histogram(result, c("H", "type2"), opacity = 0.5)

# production, use, and deposition of "type1"
type1_use <- gibbs_ad_use(result, artifacts, type = "type1",
                          max_samples = 1000, size = 500, mcse_crit = 2)
histogram(type1_use)


eratosthenes documentation built on June 28, 2025, 1:08 a.m.