Closes #420
It's a pretty simple API: The idea is that you pass the relevant by category that you want to set apart (e.g., "Unsure") to offset and we automatically calculate spacing, etc. for you.
pkgload::load_all("~/Documents/Projects/tinyplot/") #> ℹ Loading tinyplot # Employee survey: 4 questions, diverging Likert responses + an "Unsure" category lik = expand.grid( question = c("Pay", "Workload", "Manager", "Culture"), response = c("Strong disagree", "Disagree", "Agree", "Strong agree", "Unsure") ) # proportions that sum to 1 within each question m = matrix(c( .10, .20, .35, .25, .10, # Pay .25, .30, .20, .15, .10, # Workload .05, .15, .40, .35, .05, # Manager .15, .20, .30, .20, .15 # Culture ), nrow = 4, byrow = TRUE) lik$share = as.vector(m) # plot tinyplot( share ~ question | response, data = lik, type = "barplot", center = TRUE, offset = "Unsure", # type = type_barplot(center = TRUE, offset = "Unsure"), ## same flip = TRUE )
Fancier version with a diverging palette and nicer, themed aesthetic.
pal = c("#b2182b", "#ef8a62", "#67a9cf", "#2166ac", "grey") tinyplot( share ~ question | response, data = lik, type = "barplot", center = TRUE, offset = "Unsure", flip = TRUE, xlab = NA, ylab = NA, yaxl = "percent", legend = list("top!", title = NULL), theme = list("ipsum", palette.qualitative = pal), main = "Likert example with category offset", sub = "Workplace satisfaction", cap = 'Question: "I am satisified with <feature> at my work."' ) plt_add(type = 'vline')
Created on 2026-06-08 with reprex v2.1.1
HU @zeileis and @strengejacke (original suggestion on BlueSky IIRC). Edit: Found it: https://bsky.app/profile/strengejacke.de/post/3lqrkrccmgc2p