Clustered stacked bar chart using Cetz plot or other package

I know Cetz Plot supports bar charts, and can make them clustered or stacked. However, I am looking for a way to create a clustered stacked bar chart and have so far not been able to find a method to do so.

Any information or help would be appreciated.

Not the prettiest, but using some of the Typst native functions you can get somewhere close:

#let data = (
  "a": 2, "b": 3, "c": 6, "d": 2,
)

#let bar(color, height) = rect(
  width: 10pt,
  height: height * 5pt,
  fill: color,
)

#stack(dir: ltr, spacing: 20pt)[
  #for (k, v) in data {
    box(
      stack(dir: btt, spacing: 4pt)[
        #bar(blue, v)
        #k
      ]
    )
  }
]
1 Like