Hierarchical quantitative breakdowns
Compare quantities across nested categories.
Plotly · Class
go.Treemap is a Plotly trace for representing hierarchical data with nested rectangles. Its sectors are defined by labels or IDs, parent relationships, and optionally numeric values.
Instantiate go.Treemap with hierarchical labels and parent references; optional values determine sector sizes and can be aggregated according to branchvalues. Add the trace to a Figure to render the interactive rectangles.
plotly.graph_objects.Treemap(arg=None, alignmentgroup=None, ... , values=None, visible=None, **kwargs)| Name | Type | Description |
|---|---|---|
arg | dict or plotly.graph_objects.Treemap | Dictionary of properties compatible with this constructor, or an existing Treemap object. |
branchvalues | str | Controls how values are summed for branch nodes. |
labels | list | Labels displayed for sectors. |
parents | list | Parent reference for each sector. |
values | list | Numeric values used to size sectors. |
visible | bool or str | Whether to display the trace. |
A plotly.graph_objects.Treemap trace object.
labels or ids, and connect them into the hierarchy through parents.branchvalues property controls the aggregation rule for numeric values across branches.count property supplies the default value behavior when no values array is given.labels or unique ids together with matching parents entries.branchvalues deliberately because it changes how parent totals relate to descendant values.values is omitted, Plotly infers defaults rather than treating every sector as having an explicitly supplied measurement.import plotly.graph_objects as go
fig = go.Figure(go.Treemap(
labels=["Company", "Engineering", "Sales", "Backend", "Frontend"],
parents=["", "Company", "Company", "Engineering", "Engineering"],
values=[100, 60, 40, 35, 25],
))
fig.show()Creates a hierarchical treemap whose rectangles are defined by labels, parent relationships, and numeric values.
Compare quantities across nested categories.
Show how leaf items roll up into branches and a root.
Build interactive drillable category views in a Plotly figure.
go.Treemap represent, and how is its hierarchy specified?go.Treemap visualizes hierarchical data with nested rectangles. The hierarchy comes from labels or ids plus parents, while values controls the quantitative size of sectors.
Follow-up: How are parent values interpreted? branchvalues determines how values are summed across branches, so it should match whether parent values include descendants.
The constructor accepts a dictionary of compatible properties or another Treemap instance through arg, followed by trace properties such as labels, parents, values, and branchvalues. This lets callers configure the trace directly or from property mappings.
Follow-up: Why might ids be preferable to labels? IDs provide stable sector identity when displayed labels are duplicated or change.
values is omitted?When values is not supplied, the class infers a default of 1 for leaves and/or branches and otherwise 0. Explicit values are preferable when rectangle areas must represent measured quantities.
Follow-up: What should be checked when inferred values look unexpected? Inspect whether nodes are leaves or branches and provide an explicit values array when needed.
plotly.graph_objects.Figureplotly.graph_objects.Sunburstplotly.graph_objects.Icicleplotly.graph_objects.layout.template.data.Treemap