Skip to content

Marimekko

marimekko() over a long-form dataframe_mojo DataFrame (#743): one row per (subcategory, category) pair, with value holding the cell.

Marimekko

Usage

from dataviz import marimekko
from dataviz import save

def main() raises:
    var regions: List[String] = ["Northeast", "Midwest", "South", "West"]
    var sources: List[String] = ["Coal", "Gas", "Renewables"]
    var generation: List[List[Int]] = [
        [5, 20, 15, 3],
        [30, 35, 50, 20],
        [10, 15, 10, 27],
    ]

    var c = marimekko(
        regions, sources, generation, title="Energy Mix by Region"
    )
    save(c, "docs/src/examples/out_marimekko.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • category: The string column naming each column of the mosaic, whose totals set the column widths.
  • series: The string column naming each subcategory, the stacked share within a column.
  • value: The numeric column holding each cell.
  • theme: Full styling knobs beyond this function’s own parameters.
  • 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 line under the title.
  • x_title: The x-axis caption; defaults to category.
  • y_title: The y-axis caption; defaults to value.

Related

Related charts: Punchcard

Relevant API: marimekko