grantmcdermott · GitHub

Needed this for work today.

pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
tinyplot(extra ~ ID, data = sleep[sleep$group == 1, ],
  type = type_barplot(offset = 10))
# waterfall chart
d = data.frame(item = c("Sales", "Services", "Costs", "Returns", "TOTAL"),
               value = c(100, 40, -80, -10, 50))
d$item = factor(d$item, levels = d$item)
d$offset = c(0, cumsum(d$value[1:3]), 0)
tinyplot(value ~ item | I(value < 0), data = d,
  type = type_barplot(offset = d$offset), legend = FALSE)
tinyplot_add(type = type_vline(4.5), lty = 2)

Read the original on github.com ↗