Sunburst Charts

Sunburst Charts#

Multilevel pie charts are known as sunburst charts. We can create a sunburst chart using the plotly.express px.sunburst() function. Let’s say we have a family tree that we want to represent using a sunburst chart. With px.sunburst(), each row of the DataFrame is a sector of the sunburst. Each sector in the sunburst chart is analogous to a slice of the pie in a pie chart.

import plotly.express as px # import statement

# dictionary with data
data = dict(
    character=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
    parent=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
    value=[10, 14, 12, 10, 2, 6, 6, 4, 4])

# create figure
fig =px.sunburst(
    data,
    names='character',
    parents='parent',
    values='value',
)

# show figure
fig.show()

Additional Resources#