Skip to content
Streamgraph

Streamgraph

A streamgraph.

Streamgraph

Usage

from dataviz_mojo import streamgraph
from dataviz_mojo.plot import save

def main() raises:
    var years: List[String] = ["2020", "2021", "2022", "2023", "2024"]
    var genres: List[String] = ["Pop", "Rock", "Jazz"]
    var listens: List[List[Float64]] = [
        [30.0, 40.0, 55.0, 60.0, 50.0],
        [45.0, 35.0, 30.0, 25.0, 20.0],
        [10.0, 15.0, 12.0, 18.0, 25.0],
    ]

    var c = streamgraph(years, genres, listens)
    save(c, "docs/src/examples/out_streamgraph.svg")

Args:

  • categories: One position along the x-axis per entry, in the given order.
  • series_names: One flowing band per name, used as the legend key.
  • values: values[j] is series_names[j]’s value per category.
  • theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – see Theme’s docstring.
  • smoothing: Sets theme.line_smoothing – how much each band’s edges curve, [0.0, 1.0]. Defaults to 0.6, not Theme’s own 0.0: a streamgraph is meant to look like flowing water, so unlike Mark.LINE/AREA (straight by default), this one curves unless told not to. Pass 0.0 for the old straight-segment bands.
  • 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.