explore_sunburst_plot

source

explore_sunburst_plot(
    df,
    *,
    path=None,
    size=None,
    color=None,
    entity=None,
    time=None,
    max_units=200,
    sample_seed=0,
    title=None,
    subtitle=None,
)

Sunburst of a hierarchy sized by size, animated over time when available.

The radial counterpart to :func:explore_treemap_plot: concentric rings show the nested part-to-whole shares of path (e.g. countries within continents), and on a panel a play button and time slider step through the periods with a fixed color scale. Without a resolvable time id a single static sunburst is drawn.

Parameters

Name Type Description Default
df pd.DataFrame Data frame containing the hierarchy, value and (optionally) time columns. required
path list[str] | str | None Hierarchy columns from root to leaf, e.g. ["continent", "country"]. Defaults to the panel entity (a single level) when omitted. None
size str | None Numeric column mapped to wedge angle. When omitted, each leaf is sized by its row count. None
color str | None Optional column mapped to color: numeric → a fixed-range sequential colorbar; otherwise a stable discrete palette. None
entity str | None Cross-sectional (unit) id. Defaults to the panel entity; used to default path and to label leaves "Name (id)" when an entity_name is declared. None
time str | None Time identifier that drives the animation. Defaults to the panel time; when neither is available the sunburst is static. None
max_units int | None Cap on the number of distinct leaf units; above it a seeded random sample is drawn and an :class:expdpy.ExpdpyWarning is emitted. None disables sampling. 200
sample_seed int Seed for the leaf sample. 0

Returns

Name Type Description
SunburstPlotResult df (the complete-case frame plotted) and fig (the Plotly sunburst).

Examples

The same hierarchy as a radial sunburst:

import expdpy as ex
from expdpy.data import load_gapminder, load_gapminder_data_def

df = ex.set_labels(load_gapminder(), load_gapminder_data_def(), set_panel=True)
ex.explore_sunburst_plot(
    df, path=["continent", "country"], size="pop", color="lifeExp", time="year"
).fig