Skip to content
Marimekko

Marimekko

A Marimekko/mosaic chart.

Marimekko

Usage

from dataviz_mojo import marimekko
from dataviz_mojo.plot import save

def main() raises:
    var regions: List[String] = ["Northeast", "Midwest", "South", "West"]
    var sources: List[String] = ["Coal", "Gas", "Renewables"]
    var generation: List[List[Float64]] = [
        [5.0, 20.0, 15.0, 3.0],
        [30.0, 35.0, 50.0, 20.0],
        [10.0, 15.0, 10.0, 27.0],
    ]

    var c = marimekko(regions, sources, generation)
    save(c, "docs/src/examples/out_marimekko.svg")

Args:

  • categories: One column per entry, its width proportional to its share of the grand total.
  • subcategories: One stacked segment per entry, used as the legend key.
  • values: values[i][j] is subcategories[i]’s value for categories[j] (rows are subcategories, columns are categories).
  • theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – see Theme’s docstring.
  • width: Pixel width of the returned Plot (.size()).
  • height: Pixel height of the returned Plot (.size()).
  • title: The chart’s title, shown above the plot.
  • subtitle: A secondary line shown under the title.
  • x_title: The x-axis caption.
  • y_title: The y-axis caption.