Learn R Programming

vegalite (version 0.6.1)

axis_x: General axis setttings (x-axis)

Description

Axes provide axis lines, ticks and labels to convey how a spatial range represents a data range. Simply put, axes visualize scales.

By default, Vega-Lite automatically creates axes for x, y, row, and column channels when they are encoded. Axis can be customized via the axis property of a channel definition.

Usage

axis_x(vl, axisWidth = NULL, layer = NULL, offset = NULL, grid = NULL, labels = TRUE, labelAngle = NULL, labelAlign = NULL, labelBaseline = NULL, labelMaxLength = 25, shortTimeLabels = NULL, subdivide = NULL, ticks = NULL, tickPadding = NULL, tickSize = NULL, tickSizeMajor = NULL, tickSizeMinor = NULL, tickSizeEnd = NULL, title = "", titleOffset = NULL, titleMaxLength = NULL, characterWidth = 6, orient = NULL, format = NULL, remove = FALSE)

Arguments

vl
Vega-Lite object
axisWidth, layer, offset, grid, labels, labelAngle, labelAlign, labelBaseline
labelMaxLength, shortTimeLabels, subdivide, ticks, tickPadding, tickSize
tickSizeMajor, tickSizeMinor, tickSizeEnd, title, titleOffset, titleMaxLength
characterWidth, orient, format, remove

References

Vega-List Axis spec

Examples

Run this code
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(band_size=6) %>%
  scale_color_nominal(range=c("#EA98D2", "#659CCA")) %>%
  facet_col("age", "ordinal", padding=4) %>%
  axis_x(remove=TRUE) %>%
  axis_y(title="population", grid=FALSE) %>%
  axis_facet_col(orient="bottom", axisWidth=1, offset=-8) %>%
  facet_cell(stroke_width=0) %>%
  mark_bar()

Run the code above in your browser using DataLab