plot_marginals: Plot marginal distributions of real and synthetic data

View source: R/plots.R

plot_marginalsR Documentation

Plot marginal distributions of real and synthetic data

Description

plot_marginals() overlays the distributions of numeric variables (density, histogram or empirical CDF) and shows side-by-side category proportions for categorical variables. When the selected variables contain both kinds, a list of two plots (class sp_plot_list) is returned; printing it draws both.

Usage

plot_marginals(
  real,
  synthetic = NULL,
  vars = NULL,
  kind = c("density", "histogram", "ecdf"),
  max_vars = 12L,
  max_levels = 15L,
  bins = 30L
)

plot_categorical(real, synthetic = NULL, vars = NULL, max_levels = 15L)

Arguments

real

A data frame (or vector/matrix) with the real data.

synthetic

Optional synthetic data with the same columns.

vars

Variables to plot (default: all, up to max_vars per kind).

kind

For numeric variables: "density", "histogram" or "ecdf".

max_vars

Maximum number of variables of each kind shown by default.

max_levels

Maximum categories per categorical variable (the rest are pooled into "(other)").

bins

Number of histogram bins.

Value

A ggplot object or an sp_plot_list.

Examples

syn <- synthesize(iris, seed = 1)
plot_marginals(iris, syn)
plot_marginals(iris, syn, vars = "Sepal.Length", kind = "ecdf")

SynthesizerPlus documentation built on Oct. 16, 2026, 5:10 p.m.