Nested Pie charts

I took the following picture from this post. Linking traces in nested pie chart (for legend toggle functionality)

I have data that would recreate this nested pie chart however I cant seem to find the way to connect data from the outer donut with the inner donut so it will show the outer donut as part of the inner donut percentage.

Any help or guidance would be appreciated.

Here’s a simplified code that recreates the following nested pie chart (also taken from the post


import plotly.graph_objs as go

data = [# Portfolio (inner donut)
domain={‘x’:[0.2,0.8], ‘y’:[0.1,0.9]},
# Individual components (outer donut)
labels=[‘Medium Red’,‘Light Red’,‘Medium Blue’,‘Light Blue’],
domain={‘x’:[0.1,0.9], ‘y’:[0,1]},

fig = go.Figure(data=data, layout={‘title’:‘Nested Pie Chart’})


1 Like

Hi @jhurtado,

I’d recommend using the new sunburst trace type for this rather than a collection of pie traces. See for info on the sunburst trace type.

Hope that helps!


Hi John,

Thank you so much for your help. In my opinion it did work but I’m missing one last thing.

I’m trying to find the way to show as proportions which it kind of does but I was just wondering If I can control
how these proportions are shown in the plot. (e.g No whitespaces in between each other and that if I have percentages it’s shown ‘areawise’ reflected in the chart) (I hope that makes sense).

Thanks again,

Try branchvalues='total':

trace = go.Sunburst(
    labels=[ "Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
    parents=["",    "Eve",  "Eve",  "Seth", "Seth", "Eve",  "Eve",  "Awan",  "Eve" ],
    values=[  65,    14,     12,     10,     2,      6,      6,      4,       4],
    outsidetextfont = {"size": 20, "color": "#377eb8"},
    marker = {"line": {"width": 2}},

layout = go.Layout(
    margin = go.layout.Margin(t=0, l=0, r=0, b=0)

figure = {
    'data': [trace],
    'layout': layout


Hi @chriddyp,

First of all, thanks for your help! I’m trying to add that argument but it’s not working for me. I only got a white screen.

trace = go.Sunburst(
  values = [36964.92, 36964.92, 36964.92, '35H', '37H', '39H', '35H', '37H', '39H', '35H', '37H', '39H'],
  labels = ['35H', '37H', '39H', 'ballooning_%35H', 'ballooning_%37H', 'ballooning_%39H', 'normal_propagation_%35H', 'normal_propagation_%37H', 'normal_propagation_%39H', 'unknown_%35H', 'unknown_%37H', 'unknown_%39H'],
  parents = [17075.199999999997, 11883.349999999999, 8006.366666666666, 903.8166666666666, 756.5333333333333, 682.0166666666667, 4454.0, 3163.6499999999996, 2311.3166666666666, 11717.383333333335, 7963.166666666666, 5013.033333333333], 
  outsidetextfont={"size": 20, "color": "#377eb8"},
  leaf={"opacity": 0.4},
  marker={"line": {"width": 2}},

layout = go.Layout(
    margin = go.layout.Margin(t=0, l=0, r=0, b=0)

fig = go.Figure([trace], layout)


I made sure that every branch value not was higher than the total which may create the error. May it be the way set up branches?

any help would be appreciate it.

Hi @jhurtado,

I think there may be a problem with your specification of the parents array. The elements of parents need to match elements of values, but that doesn’t seem to be the case in this example.

Hope that helps,

Thanks Jon,

I really appreciate your help and you were right it was something about the configuration on the parents array designation.

I was able to finish one part of it and now I’m working on the other two.

Thanks for your help and also @chriddyp



Large number of slices is not working for sunburst charts even if parents and value array matches

I am working on the sunburst charts too. I also want to display the percentage values with respect to parent for the leaves. Is there a way to include percentage along with the labels on the sunburst chart?

This is exactly what I needed to complete a complex visualization. The key piece I was missing was the domain attribute on my inner sunburst chart. :+1: