Skip to content

offset for type_barplot#611

Merged
grantmcdermott merged 6 commits into
mainfrom
bar-offset
Jun 6, 2026
Merged

offset for type_barplot#611
grantmcdermott merged 6 commits into
mainfrom
bar-offset

Conversation

@grantmcdermott
Copy link
Copy Markdown
Owner

@grantmcdermott grantmcdermott commented Jun 6, 2026

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)

Created on 2026-06-05 with reprex v2.1.1

HU @zeileis (one step towards #420)

@grantmcdermott grantmcdermott merged commit 77c815b into main Jun 6, 2026
3 checks passed
@grantmcdermott grantmcdermott deleted the bar-offset branch June 6, 2026 03:07
@zeileis
Copy link
Copy Markdown
Collaborator

zeileis commented Jun 7, 2026

Very nice with a clear example!

In #420 I have now added a worked example how this could be used of displaying a "don't know" category on the side. It's not completely obvious but doable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants