This plots distributions identified by find_possible_distributions using ggplot2. They can be shown as histograms or as cumulative distributions (ECDF) plots. The latter give more information, yet not all audiences are familiar with them.

plot_distributions(
  distributions,
  plot_type = c("auto", "histogram", "ecdf", "density"),
  max_plots = 100,
  show_ids = FALSE,
  facets = NULL
)

Arguments

distributions

Nonempty tibble with a list-column distribution containing nonempty, finite numeric vectors, and an identifier (id), typically as returned from find_possible_distributions. Density plots require at least two distinct responses in each distribution.

plot_type

Plot multiple histograms, or overlapping cumulative distribution plots, or density plots? "auto" is to plot histograms if up to 9 distributions are passed, or if there are fewer than 10 discrete values, and empirical cumulative distribution plots otherwise

max_plots

Positive integer: how many distributions should at most be plotted? If more are passed, this number is randomly selected.

show_ids

Should ids of the distributions be shown with ecdf and density charts? Defaults to no, since the default ids are not meaningful.

facets

Should distributions be shown in one chart or in multiple small charts? Only considered for ecdf and density charts, histograms are always shown in facets

Value

A ggplot2 object that can be styled with functions such as labs or theme_linedraw

Details

Histograms show the exact frequency at each observed response. Bar widths use the response spacing (1 / n_items) for SPRITE results. For ordinary tibbles, widths use the smallest observed spacing, or 1 if all responses are identical. Scale endpoints and complete bars are retained. Empty inputs produce an informative error.

Examples

sprite_parameters <- set_parameters(mean = 2.2, sd = 1.3, n_obs = 20,
                                    min_val = 1, max_val = 5)

poss <- find_possible_distributions(sprite_parameters, 5, seed = 1234)

# All distributions in same plot
plot_distributions(poss, plot_type = "ecdf")


# Separate plot for each distribution
plot_distributions(poss, plot_type = "ecdf", facets = TRUE)