scale_vl: Vega-Lite Scales

Description Usage Arguments References Examples

Description

Vega-Lite Scales

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

Arguments

vl

Vega-Lite object

chnl

x,y,color,shape

type

linear, log, pow, sqrt, quantize, quantile, threshold, time, ordinal

domain

Custom domain values. For quantitative data, this can take the form of a two-element array with minimum and maximum values.

range

The range of the scale represents the set of output visual values. Vega-Lite automatically determines appropriate range based on the scale’s channel and type, but range property can be provided to customize range values.

scheme

color scheme to use

round

If true, rounds numeric output values to integers.

clamp

if true, values that exceed the data domain are clamped to either the minimum or maximum range value. Default value: derived from scale config (true by default) Supported Types: only linear, pow, sqrt, and log

exponent

in the "pow" scale only, expresses each range value y as a power (exponential) function of the domain value x: y = mx^k + b where k is exponent

base

log base to use for log scale

nice

If true, modifies the scale domain to use a more human-friendly number range (e.g., 7 instead of 6.96). Default value: true only for quantitative x and y scales and false otherwise.

zero

If true, ensures that a zero baseline value is included in the scale domain. Default value: true if the quantitative field is not binned.

useRawDomain

If true, set scale domain to the raw data domain. If false, use the aggregated data domain for scale.

band_size

Deprecated – use range_step instead.

range_step

Width for each x or y ordinal band. This can be an integer value or a string "fit". For "fit", the band size will be automatically adjusted to fit the scale for the specified width (for x-axis) or height (for y-axis).

padding

For x and y channels, the padding is a multiple of the spacing between points. A reasonable value is 1.0, such that the first and last point will be offset from the minimum and maximum value by half the distance between points. (See D3’s ordinalRangePoints() for illustration.)

interpolate

interpolation method to use for ranges. Legal values include rgb, hsl, hsl-long, lab, hcl, hcl-long, cubehelix and cubehelix-long

...

additional arguments to pass to scale_vl

References

Vega-Lite Scales spec

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/population.json") %>%
  add_filter("datum.year == 2000") %>%
  calculate("gender", 'datum.sex == 2 ? "Female" : "Male"') %>%
  encode_x("gender", "nominal") %>%
  encode_y("people", "quantitative", aggregate="sum") %>%
  encode_color("gender", "nominal") %>%
  scale_x_ordinal_vl(range_step=8) %>%
  scale_color_nominal_vl(range=c("#EA98D2", "#659CCA")) %>%
  facet_col("age", "ordinal") %>%
  axis_x(remove=TRUE) %>%
  axis_y(title="population", grid=FALSE) %>%
  view_config(stroke_width=0) %>%
  mark_bar()

hrbrmstr/vegalite documentation built on May 17, 2019, 5:38 p.m.