Skip to contents

Add DensityTransform to a vega-lite spec.

Usage

vl_density(
  spec,
  density = NULL,
  as = NULL,
  bandwidth = NULL,
  counts = NULL,
  cumulative = NULL,
  extent = NULL,
  groupby = NULL,
  maxsteps = NULL,
  minsteps = NULL,
  steps = NULL,
  .object = NULL
)

Arguments

spec

An input vega-lite spec

density

The data field for which to perform density estimation.

as

The output fields for the sample value and corresponding density estimate.

Default value: ["value", "density"]

bandwidth

The bandwidth (standard deviation) of the Gaussian kernel. If unspecified or set to zero, the bandwidth value is automatically estimated from the input data using Scott’s rule.

counts

A boolean flag indicating if the output values should be probability estimates (false) or smoothed counts (true).

Default value: false

cumulative

A boolean flag indicating whether to produce density estimates (false) or cumulative density estimates (true).

Default value: false

extent

A [min, max] domain from which to sample the distribution. If unspecified, the extent will be determined by the observed minimum and maximum values of the density value field.

groupby

The data fields to group by. If not specified, a single group containing all data objects will be used.

maxsteps

The maximum number of samples to take along the extent domain for plotting the density.

Default value: 200

minsteps

The minimum number of samples to take along the extent domain for plotting the density.

Default value: 25

steps

The exact number of samples to take along the extent domain for plotting the density. If specified, overrides both minsteps and maxsteps to set an exact number of uniform samples. Potentially useful in conjunction with a fixed extent to ensure consistent sample points for stacked densities.

.object

Directly input an object, rather than creating one via the other arguments. Should not be used in conjunction with the other arguments other than spec. Objects can be of type: DensityTransform

Value

A modified Vega-Lite Spec