tests/specs/line.r

# Basic line graphs
library(ggvis)
library(dplyr, warn.conflicts = FALSE)

set.seed(1780)
df <- data.frame(x = runif(12), y = runif(12), z = gl(3, 4),
                 w = factor(rep(letters[1:4], 3)))

df %>%
  ggvis(x = ~x, y = ~y) %>%
  layer_paths() %>%
  save_spec("line/basic.json")

df %>%
  ggvis(x = ~x, y = ~y) %>%
  arrange(x) %>%
  layer_paths() %>%
  save_spec("line/sort.json")

df %>%
  ggvis(x = ~x, y = ~y, stroke = ~z) %>%
  layer_lines() %>%
  save_spec("line/layer-line.json")

# Auto-grouping for lines with nominal x
df %>%
  ggvis(x = ~w, y = ~y, stroke = ~z) %>%
  layer_lines() %>%
  save_spec("line/layer-line-nominal-x.json")

Try the ggvis package in your browser

Any scripts or data that you put into this service are public.

ggvis documentation built on May 29, 2024, 1:12 a.m.