Streamgraph
streamgraph() over a long-form dataframe_mojo DataFrame (#743): one row per (series, category) pair, with value holding the cell.
Usage
from dataviz import streamgraph
from dataviz import save
def main() raises:
var years: List[String] = [
"2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024",
]
var genres: List[String] = [
"Pop", "Hip-hop", "Rock", "Electronic", "Country",
]
var listens: List[List[Int]] = [
[42, 45, 48, 52, 57, 63, 67, 71, 74],
[24, 29, 36, 44, 53, 64, 72, 80, 87],
[55, 53, 50, 48, 46, 45, 44, 43, 42],
[16, 20, 25, 31, 38, 46, 55, 63, 70],
[27, 28, 30, 31, 34, 38, 42, 47, 52],
]
var c = streamgraph(
years,
genres,
listens,
title="Illustrative Listening Hours by Genre (millions)",
x_title="Year",
)
save(c, "docs/src/examples/out_streamgraph.svg")See Data shapes for shared input conventions.
Args:
df: The frame to read.category: The string column naming each category.series: The string column naming each band.value: The numeric column holding each cell.smoothing: How much each band curves; see the list overload.theme: Full styling knobs beyond this function’s own parameters.width: Pixel width of the returnedPlot(.size()).height: Pixel height of the returnedPlot(.size()).title: The chart’s title, shown above the plot.subtitle: A line under the title.x_title: The x-axis caption; defaults tocategory.
Related
Related charts: Span Chart · Stacked Area
Relevant API: streamgraph