Skip to contents

Add scale parameters to an encoding

Usage

vl_scale_angle(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_color(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_fill(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_fillOpacity(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_opacity(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_radius(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_shape(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_size(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_stroke(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_strokeDash(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_strokeOpacity(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_strokeWidth(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_theta(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_x(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_xOffset(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_y(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

vl_scale_yOffset(
  spec,
  align = NULL,
  base = NULL,
  bins = NULL,
  clamp = NULL,
  constant = NULL,
  domain = NULL,
  domainMax = NULL,
  domainMid = NULL,
  domainMin = NULL,
  exponent = NULL,
  interpolate = NULL,
  nice = NULL,
  padding = NULL,
  paddingInner = NULL,
  paddingOuter = NULL,
  range = NULL,
  rangeMax = NULL,
  rangeMin = NULL,
  reverse = NULL,
  round = NULL,
  scheme = NULL,
  type = NULL,
  zero = NULL,
  .object = NULL
)

Arguments

spec

An input vega-lite spec

align

The alignment of the steps within the scale range.

This value must lie in the range [0,1]. A value of 0.5 indicates that the steps should be centered within the range. A value of 0 or 1 may be used to shift the bands to one side, say to position them adjacent to an axis.

Default value: 0.5

base

The logarithm base of the log scale (default 10).

bins

Bin boundaries can be provided to scales as either an explicit array of bin boundaries or as a bin specification object. The legal values are:

  • An array literal of bin boundary values. For example, [0, 5, 10, 15, 20]. The array must include both starting and ending boundaries. The previous example uses five values to indicate a total of four bin intervals: [0-5), [5-10), [10-15), [15-20]. Array literals may include signal references as elements.

  • A bin specification object that indicates the bin step size, and optionally the start and stop boundaries.

  • An array of bin boundaries over the scale domain. If provided, axes and legends will use the bin boundaries to inform the choice of tick marks and text labels.

[15-20]: R:15-20%5C [bin specification object]: R:bin%20specification%0Aobject

clamp

If true, values that exceed the data domain are clamped to either the minimum or maximum range value

Default value: derived from the scale config's clamp (true by default).

constant

A constant determining the slope of the symlog function around zero. Only used for symlog scales.

Default value: 1

domain

Customized domain values in the form of constant values or dynamic values driven by a parameter.

  1. Constant domain for quantitative fields can take one of the following forms:

  • A two-element array with minimum and maximum values. To create a diverging scale, this two-element array can be combined with the domainMid property.

  • An array with more than two entries, for Piecewise quantitative scales.

  • A string value "unaggregated", if the input field is aggregated, to indicate that the domain should include the raw data values prior to the aggregation.

  1. Constant domain for temporal fields can be a two-element array with minimum and maximum values, in the form of either timestamps or the DateTime definition objects.

  2. Constant domain for ordinal and nominal fields can be an array that lists valid input values.

  3. To combine (union) specified constant domain with the field's values, domain can be an object with a unionWith property that specify constant domain to be combined. For example, domain: {unionWith: \[0, 100\]} for a quantitative scale means that the scale domain always includes [0, 100], but will include other values in the fields beyond [0, 100].

  4. Domain can also takes an object defining a field or encoding of a parameter that interactively determines the scale domain.

domainMax

Sets the maximum value in the scale domain, overriding the domain property. This property is only intended for use with scales having continuous domains.

domainMid

Inserts a single mid-point value into a two-element domain. The mid-point value must lie between the domain minimum and maximum values. This property can be useful for setting a midpoint for diverging color scales. The domainMid property is only intended for use with scales supporting continuous, piecewise domains.

domainMin

Sets the minimum value in the scale domain, overriding the domain property. This property is only intended for use with scales having continuous domains.

exponent

The exponent of the pow scale.

interpolate

The interpolation method for range values. By default, a general interpolator for numbers, dates, strings and colors (in HCL space) is used. For color ranges, this property allows interpolation in alternative color spaces. Legal values include rgb, hsl, hsl-long, lab, hcl, hcl-long, cubehelix and cubehelix-long ('-long' variants use longer paths in polar coordinate spaces). If object-valued, this property accepts an object with a string-valued type property and an optional numeric gamma property applicable to rgb and cubehelix interpolators. For more, see the d3-interpolate documentation.

  • Default value: hcl

nice

Extending the domain so that it starts and ends on nice round values. This method typically modifies the scale’s domain, and may only extend the bounds to the nearest round value. Nicing is useful if the domain is computed from data and may be irregular. For example, for a domain of [0.201479…, 0.996679…], a nice domain might be [0.2, 1.0].

For quantitative scales such as linear, nice can be either a boolean flag or a number. If nice is a number, it will represent a desired tick count. This allows greater control over the step size used to extend the bounds, guaranteeing that the returned ticks will exactly cover the domain.

For temporal fields with time and utc scales, the nice value can be a string indicating the desired time interval. Legal values are "millisecond", "second", "minute", "hour", "day", "week", "month", and "year". Alternatively, time and utc scales can accept an object-valued interval specifier of the form {"interval": "month", "step": 3}, which includes a desired number of interval steps. Here, the domain would snap to quarter (Jan, Apr, Jul, Oct) boundaries.

Default value: true for unbinned quantitative fields without explicit domain bounds; false otherwise.

padding

For continuous scales, expands the scale domain to accommodate the specified number of pixels on each of the scale range. The scale range must represent pixels for this parameter to function as intended. Padding adjustment is performed prior to all other adjustments, including the effects of the zeronicedomainMin, and domainMax properties.

For band scales, shortcut for setting paddingInner and paddingOuter to the same value.

For point scales, alias for paddingOuter.

Default value: For continuous scales, derived from the scale config's continuousPadding. For band and point scales, see paddingInner and paddingOuter. By default, Vega-Lite sets padding such that width/height = number of unique values * step.

paddingInner

The inner padding (spacing) within each band step of band scales, as a fraction of the step size. This value must lie in the range [0,1].

For point scale, this property is invalid as point scales do not have internal band widths (only step sizes between bands).

Default value: derived from the scale config's bandPaddingInner.

paddingOuter

The outer padding (spacing) at the ends of the range of band and point scales, as a fraction of the step size. This value must lie in the range [0,1].

Default value: derived from the scale config's bandPaddingOuter for band scales and pointPadding for point scales. By default, Vega-Lite sets outer padding such that width/height = number of unique values * step.

range

The range of the scale. One of:

  • A string indicating a pre-defined named scale range (e.g., example, "symbol", or "diverging").

  • For continuous scales, two-element array indicating minimum and maximum values, or an array with more than two entries for specifying a piecewise scale.

  • For discrete and discretizing scales, an array of desired output values or an object with a field property representing the range values. For example, if a field color contains CSS color names, we can set range to {field: "color"}.

Notes:

  1. For color scales you can also specify a color scheme instead of range.

  2. Any directly specified range for x and y channels will be ignored. Range can be customized via the view's corresponding size (width and height).

rangeMax

Sets the maximum value in the scale range, overriding the range property or the default range. This property is only intended for use with scales having continuous ranges.

rangeMin

Sets the minimum value in the scale range, overriding the range property or the default range. This property is only intended for use with scales having continuous ranges.

reverse

If true, reverses the order of the scale range. Default value: false.

round

If true, rounds numeric output values to integers. This can be helpful for snapping to the pixel grid.

Default value: false.

scheme

A string indicating a color scheme name (e.g., "category10" or "blues") or a scheme parameter object.

Discrete color schemes may be used with discrete or discretizing scales. Continuous color schemes are intended for use with color scales.

For the full list of supported schemes, please refer to the Vega Scheme reference.

type

The type of scale. Vega-Lite supports the following categories of scale types:

  1. Continuous Scales -- mapping continuous domains to continuous output ranges ("linear", "pow", "sqrt", "symlog", "log", "time", "utc".

  2. Discrete Scales -- mapping discrete domains to discrete ("ordinal") or continuous ("band" and "point") output ranges.

  3. Discretizing Scales -- mapping continuous domains to discrete output ranges "bin-ordinal", "quantile", "quantize" and "threshold".

Default value: please see the scale type table.

zero

If true, ensures that a zero baseline value is included in the scale domain.

Default value: true for x and y channels if the quantitative field is not binned and no custom domain is provided; false otherwise.

Note: Log, time, and utc scales do not support zero.

.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: Scale

Value

A modified Vega-Lite Spec