mark: Mark

Description Usage Arguments References Examples

Description

A bar mark represents each data point as a rectangle, where the length is mapped to a quantitative scale.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
mark(vl, mark = "circle", filled = NULL, color = NULL, fill = NULL,
  stroke = NULL, opacity = NULL, fillOpacity = NULL,
  strokeOpacity = NULL, strokeWidth = NULL, strokeDash = NULL,
  strokeDashOffset = NULL, stacked = NULL, interpolate = NULL,
  tension = NULL, orient = NULL, barSize = NULL, shape = NULL,
  size = NULL, tickSize = NULL, tickThickness = NULL)

mark_bar(vl, ...)

mark_circle(vl, ...)

mark_square(vl, ...)

mark_tick(vl, ...)

mark_line(vl, ...)

mark_area(vl, ...)

mark_point(vl, ...)

mark_text(vl, ...)

Arguments

vl

Vega-Lite object

mark

can be "bar", "circle", "square", "tick", "line", "area", "point", and "text". These directly set how the data are drawn and are similar geoms in ggplot2.

filled, color, fill, stroke

see config.mark color docs

opacity, fillOpacity, strokeOpacity

see config.mark opacity docs

strokeWidth, strokeDash, strokeDashOffset

see config.mark stroke docs

stacked

Defunct; Use in encode_x or encode_y

interpolate, tension

for line and area mark, the line interpolation method. value for interpolate can be "linear", "step-before", "step-after", "basis", "basis-open", "basis-closed", "bundle", "cardinal", "cardinal-open", "cardinal-closed", or "monotone", For tension, see D3's line interpolation.

orient

the orientation of a non-stacked bar, area, and line charts. The value is either "horizontal", or "vertical" (default). For bar and tick, this determines whether the size of the bar and tick should be applied to x or y dimension. For area, this property determines the orient property of the Vega output. For line, this property determines the path order of the points in the line if path channel is not specified. For stacked charts, this is always determined by the orientation of the stack; therefore explicitly specified value will be ignored.

barSize

the size of the bars (width or height depending on orient)

shape

applicable to point mark, "circle", "square", "cross", "diamond", "triangle-up", or "triangle-down", or else a custom SVG path string.

size

for point, circle or square mark, the pixel area of a point.

tickSize

the size of ticks

tickThickness

the thickness of ticks.

...

additional arguments passed to mark

References

Vega-Lite Mark spec, Vega-Lite config.mark spec

Examples

 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
dat <- jsonlite::fromJSON('[
    {"a": "A","b": 28}, {"a": "B","b": 55}, {"a": "C","b": 43},
    {"a": "D","b": 91}, {"a": "E","b": 81}, {"a": "F","b": 53},
    {"a": "G","b": 19}, {"a": "H","b": 87}, {"a": "I","b": 52}
  ]')

vegalite() %>%
  add_data(dat) %>%
  encode_x("a", "ordinal") %>%
  encode_y("b", "quantitative") %>%
  mark_bar()
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", "quantitative") %>%
  encode_y("Miles_per_Gallon", "quantitative") %>%
  mark_circle()
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", "quantitative") %>%
  encode_y("Miles_per_Gallon", "quantitative") %>%
  mark_circle()
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", "quantitative") %>%
  encode_y("Miles_per_Gallon", "quantitative") %>%
  mark_square()
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", "quantitative") %>%
  encode_y("Cylinders", "ordinal") %>%
  mark_tick()
vegalite() %>%
  view_size(300, 300) %>%
  add_data("https://vega.github.io/vega-editor/app/data/driving.json") %>%
  encode_x("miles", "quantitative") %>%
  encode_y("gas", "quantitative") %>%
  encode_order("year", "temporal") %>%
  scale_x_linear_vl(zero=FALSE) %>%
  scale_y_linear_vl(zero=FALSE) %>%
  mark_line()
vegalite() %>%
  view_size(300, 200) %>%
  add_data("https://vega.github.io/vega-editor/app/data/unemployment-across-industries.json") %>%
  encode_x("date", "temporal") %>%
  encode_y("count", "quantitative", aggregate="sum") %>%
  encode_color("series", "nominal") %>%
  scale_color_nominal_vl(scheme="category20b") %>%
  timeunit_x("yearmonth") %>%
  scale_x_time_vl(nice="month") %>%
  axis_x(format="%Y", labelAngle=0) %>%
  mark_area()
vegalite() %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", "quantitative") %>%
  encode_y("Miles_per_Gallon", "quantitative") %>%
  mark_point()
vegalite() %>%
  view_size(300, 200) %>%
  add_data("https://vega.github.io/vega-editor/app/data/cars.json") %>%
  encode_x("Horsepower", "quantitative") %>%
  encode_y("Miles_per_Gallon", "quantitative") %>%
  encode_color("Origin", "nominal") %>%
  calculate("OriginInitial", "datum.Origin[0]") %>%
  encode_text("OriginInitial", "nominal") %>%
  mark_text()

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