Sunburst Charts
When to use sunburst charts
Sunburst charts are for hierarchical breakdowns, where each level nests inside the one before it:
- Region → City → Store
- Category → Subcategory → Product
The center ring is the top of the hierarchy; each ring further out is one level deeper. A segment’s angle (arc width) is proportional to its value, so you can see both “how big is this branch” and “how does it split further” in one picture. Use sunbursts when the hierarchy itself is part of the story — not just as a fancier pie chart.
Example
import pandas as pd
import plotly.express as px
df = pd.DataFrame({
"region": ["West", "West", "North", "North"],
"city": ["Pune", "Mumbai", "Delhi", "Chandigarh"],
"sales": [120, 90, 180, 60],
})
fig = px.sunburst(df, path=["region", "city"], values="sales", title="Sales hierarchy")
fig.show()import pandas as pd
import plotly.express as px
df = pd.DataFrame({
"region": ["West", "West", "North", "North"],
"city": ["Pune", "Mumbai", "Delhi", "Chandigarh"],
"sales": [120, 90, 180, 60],
})
fig = px.sunburst(df, path=["region", "city"], values="sales", title="Sales hierarchy")
fig.show()path=["region", "city"]path=["region", "city"] tells Plotly the nesting order (outermost group first); values="sales"values="sales" sizes every arc. Clicking a ring segment in the rendered chart zooms into that branch — a built-in drill-down for free.
Tip
If your hierarchy is large, sunburst can become cluttered — thin outer rings become unreadable slivers. Consider bar charts (or a treemap) for top-level summaries, and reserve the sunburst for cases where the drill-down interaction genuinely helps.
flowchart TD A["DataFrame rows"] --> B["path=['region', 'city']
defines ring order"] B --> C["Ring 1 (inner) = region
arc width ∝ sum(sales)"] B --> D["Ring 2 (outer) = city
arc width ∝ sales"] C --> E["Click a ring segment
to zoom into that branch"] D --> E
Next
Continue to: 3D Scatter Plots for exploring three numeric variables at once.
🧪 Try It Yourself
Exercise 1 – Define the Hierarchy Path
Exercise 2 – Size Arcs by a Value Column
Exercise 3 – Three-Level Hierarchy
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
