Vega-Lite Grouped Bar

A grouped (clustered) bar chart where each category gets a side-by-side cluster of sub-series, all driven by Vega-Lite's `xOffset` channel — the cleanest way to encode a categorical sub-grouping in any grammar-of-graphics library. The spec is a single `bar` mark with `x` for the

Template details

  • chart
  • bar
  • grouped
  • comparison
  • vega
  • vega-lite

When to use this template

This visualization excels at comparing the performance or distribution of a small number of distinct sub-categories within larger, discrete categories. It allows for direct side-by-side comparison of sub-groups, making it easy to spot trends, outliers, or differences in magnitude across the primary categorical axis. An analyst would choose this to understand how specific sub-segments contribute or vary within each main group.

  • Datasets with a primary categorical axis and a secondary, low-cardinality categorical sub-group.
  • Quantitative values for direct comparison across sub-groups.
  • When comparing 2-5 sub-series per main category to avoid clutter.
  • Discrete, non-ordinal primary categories.
  • Data where the absolute value of each sub-group is important, not just its proportion.
  • Cross-sectional or time-series data where the time dimension is a primary category.

Browse all Koan templates