Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bar Charts

Signature

sp.bar(title, labels=None, values=None, *, variant="basic", series=None, series_names=None, theme="none", **kwargs) -> Chart

Aliases: sp.bar_chart(), sp.bars(), sp.bar_unified(), sp.bars_unified(), sp.bar_family().

Description

sp.bar() is the unified entry point for the SeraPlot bar-chart family. It renders standalone Rust-generated HTML/SVG charts. The variant keyword selects the renderer, and shared chart options are applied by the common chart pipeline.

The default renderer is a vertical categorical bar chart. The same API also covers every bar variant registered in Rust.

Variants

Data

labels are category labels for bar variants. Single-series variants use values. Multi-series variants use series, where each inner list is one series, and series_names supplies legend names.

When series is missing but series_names is provided, values is interpreted as a flattened matrix split by len(labels): the first category-length block is the first series, the next block is the second series, and so on.

Parameters

Themes

Returns

Chart object with an .html property and a .show() method.

Variant "basic"Aliases sp.bar sp.bars sp.bar_unifiedReturns Chart
Preview

Horizontal bars — better for long category names. Alias: "h".

Variant "horizontal" / "h"Aliases sp.bar + variant="h"Returns Chart
Preview

Multiple series side-by-side per category. Alias: "group".

Variant "grouped" / "group"Required series, series_namesReturns Chart
Preview

Series stacked vertically — shows part-to-whole within each category. Alias: "stack".

Variant "stacked" / "stack"Required series, series_namesReturns Chart
Preview

100% stacked bars — every column fills from 0 to 100%, showing each series as a share of the total. Alias: "rel".

Variant "relative" / "rel"Required series, series_namesNote each column normalised to 100%Returns Chart
Preview

Groups of stacked sub-bars per category. offset_groups assigns a stack-group name to each series.

Variant "grouped_stacked"Required series, offset_groupsReturns Chart
Preview

Variable-width stacked bars (mosaic plot). widths encodes one dimension, stacked segments encode share. Aliases: "mekko", "mosaic".

Variant "marimekko" / "mekko" / "mosaic"Required series, widthsReturns Chart
Preview

A bar made of repeated icons. Each icon represents units_per_icon units. Alias: "icon".

Variant "pictogram" / "icon"Required values, units_per_iconReturns Chart
Preview

Two-level hierarchical x axis. super_categories groups adjacent bars under a bracket label. Alias: "multi".

Variant "multicategory" / "multi"Required values, super_categoriesReturns Chart
Preview

Bars arranged radially around a center, length proportional to value. Pass show_values=True for a value at each bar's tip, gridlines=True for labeled concentric rings. Aliases: "circular_basic", "radial_bar", "polar_bar".

Variant "circular"Required labels, valuesOptional show_values, gridlinesReturns Chart
Preview

Circular bars split into groups via color_groups, with an extra gap between groups. Same show_values/gridlines options as circular. Aliases: "radial_grouped", "circular_groups".

Variant "circular_grouped"Required labels, values, color_groupsReturns Chart
Preview

Two horizontal bar sets mirrored left/right around a shared category axis, from the first two entries of series. Aliases: "pyramid", "age_pyramid".

Variant "population_pyramid"Required labels, series (≥ 2), series_namesReturns Chart
Preview

Horizontal bars extending left or right from a zero line, one color regardless of sign, value printed inside the bar (white) when it's wide enough or just outside otherwise. Aliases: "signed", "delta", "bidirectional". The value label is controlled by show_values (bool) like every other bar variant — it defaults to True here so existing charts keep their look, unlike other variants where it defaults to False.

Variant "diverging"Required labels, valuesReturns Chart
Preview

Bar + boxplot fusion: a semi-transparent bar up to each category's mean, with a real box (Q1/median/Q3, whiskers) overlaid on top showing the distribution behind that mean — pass series as one raw sample array per category (same shape as boxplot's grouped input) instead of single aggregate values. Aliases: "bar_box", "boxbar", "bar_boxplot".

Variant "distribution"Required labels, seriesReturns Chart
Preview