Grouped Bar
grouped_bar() over a long-form dataframe_mojo DataFrame (#743): one row per (series, category) pair, with value holding the cell.
Usage
from dataviz import grouped_bar
from dataviz import save
def main() raises:
var quarters: List[String] = ["Q1", "Q2", "Q3", "Q4"]
var series_names: List[String] = ["North", "South", "East"]
var values: List[List[Int]] = [
[42, 48, 45, 61],
[30, 35, 33, 40],
[55, 50, 58, 66],
]
var c = grouped_bar(
quarters,
series_names,
values,
title="Quarterly Revenue by Region",
x_title="Quarter",
y_title="Revenue ($M)",
)
save(c, "docs/src/examples/out_grouped_bar.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 series.value: The numeric column holding each cell.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.y_title: The y-axis caption; defaults tovalue.horizontal: Draw the categories down the y axis instead.
Related
Related charts: Lollipop · Stacked Bar
Relevant API: grouped_bar