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 Chart 3D

Signature

sp.bar3d(title, labels=None, values=None, *, variant="basic", series=None, series_names=None, orientation3d="iso", color_hex=0x6366F1, palette=None, bg_color="#1a1a2e", width=900, height=560, x_label="", y_label="", z_label="", **kwargs) -> Chart

Aliases: sp.build_bar3d_chart(), sp.bar_3d(), sp.bar3d_chart(), sp.bar3d_family(), sp.bars3d().

Description

sp.bar3d() renders the SeraPlot bar family as extruded prisms on an interactive 3D canvas. It is the 3D twin of sp.bar(): every one of the 17 bar variants has a 3D form, selected with the same variant= keyword and fed with the same data fields. Layouts come from shared, family-agnostic strategies (linear, grouped, stacked, radial, spiral, box-and-whisker), so geometry is never hand-written per variant.

Variants

VariantAliasesUses3D form
basic—labels, valuesOne extruded column per category along the X axis; height encodes the value.
horizontalh, hbarlabels, valuesBars lie flat along the X axis, one row per category; length encodes the value.
groupedgrouplabels, series, series_namesSeries side by side in depth: one row of columns per series, categories along X.
stackedstacklabels, series, series_namesSeries stacked into a single column per category; each segment keeps its series colour.
relativerellabels, series, series_namesStacked columns normalised to 100 %: every column reaches the same height, segments show the share.
grouped_stackedgroupstack, grouped-stackedlabels, series, offset_groupsStack groups placed side by side in depth, each stack built from its own series segments.
marimekkomekko, mosaiclabels, series, widthsColumns whose footprint width follows widths, stacked segments encode each series share.
pictogramiconlabels, values, units_per_iconEvery icon becomes a small block; blocks pile up in columns of max_icons_per_column.
multicategorymulti, hierarchicallabels, values, super_categoriesColumns grouped under their super_categories, with an extra gap between two groups.
circularcircular_basic, radial_bar, polar_barlabels, valuesColumns stand on a ring, one per category; height encodes the value.
circular_groupedradial_grouped, circular_groupslabels, values, color_groupsThe same ring split into angular arcs by color_groups, one colour per group.
population_pyramidpyramid, age_pyramidlabels, series, series_namesTwo back-to-back rows of columns, one per series (male / female), age groups along X.
divergingsigned, delta, bidirectionallabels, valuesColumns rise above or sink below the floor with the sign of the value; with series, positive and negative segments stack on each side.
distributionbar_box, boxbar, bar_boxplotlabels, seriesFor each sample a slim column spans the whiskers and a wider box spans the interquartile range.
spiralspiral_bar, nautilus, radial_spiral, growth_spirallabels, valuesColumns follow an outward spiral, one per index — made for long time series.
hedgehogflow_fan, quill, spike_flow, relocation_fanlabels, valuesSigned spikes around a ring: positive values rise, negative values sink.
radial_flowcapital_flow, hierarchical_radial, sankey_radial, flow_arclabels, values, super_categoriesA ring split into arcs by super_categories, columns grouped under their parent.

3D planes

The viewpoint is independent from the variant: orientation3d (aliases tilt3d, rotate3d) picks the initial camera plane and applies to every variant. The plane can also be switched afterwards with .orient3d(mode), and the view always stays draggable.

orientation3d="iso" — Isometric three-quarter view (default).
orientation3d="horizontal" — Side-on view, almost at floor level.
orientation3d="vertical" — Top-down view from above.
orientation3d="front" — Front elevation, nearly flat.
chart = sp.bar3d("Sales", variant="grouped", labels=labels, series=series, series_names=names, orientation3d="vertical")
chart = chart.orient3d("front")

3D scenes

The scene is a second independent axis: scene swaps the environment the bars are drawn in and applies to every variant too. Every scene works with every plane.

scene="default" — Each series keeps its own categorical palette color, rendered as shaded 3D bars on a flat grid.
scene="terrain" — The data is resampled onto a dense grid and rendered as hundreds of thin colormap-colored columns, forming a continuous mountain-of-bars terrain.
scene="tower" — The data is resampled onto a dense field of round skyscraper-like towers instead of boxes, for a city-skyline reading of magnitude.
scene="radial" — The data is resampled onto a dense polar grid of rings and wedges radiating from the center, like a 3D radar/sonar sweep of the value field.
scene="podium" — The data is resampled onto a dense grid and quantized into stepped terrace levels, like a rice-terrace contour map, to read value bands at a glance.
chart = sp.bar3d("Sales", variant="spiral", labels=years, values=counts, scene="terrain", orientation3d="vertical")

Themes

theme restyles the whole canvas (colour grade and glow) and applies to every variant, scene and plane. Sorting follows the 2D chart too: sort_order="desc" reorders the columns of every single-series variant.

theme="deluxe"
theme="prism"
theme="aurora"
theme="inferno"
theme="frost"
theme="glow"
theme="glass"
theme="neon"
theme="cosmic"

Auto-scaling zone

The 3D zone (floor, walls, axes and camera) scales to the elements: its length, width and height follow the extents of the drawn blocks, a minimum floor depth keeps single rows readable, wide scenes are drawn flatter and the camera frames the whole box. The axis ticks read the real data range. Pass zone=[x, y, z] to force the proportions of the box instead; the longest side is normalised to 1.

Parameters

Returns

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