Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Large number of slices for sunburst chart is not working

(upload://zBgtBbnrLpbQdlzMZcHeFB1jEkv.png) Large number of slices for sunburst charts which is working in your case https://plot.ly/python/sunburst-charts/ is not working in my case, it just appears a blank white screen without any charts.
length of labels , ids , parents is 74 ( with repetition),

but it works fine (chart appears properly) if the length of the labels,ids,parents is 35 (with repetition).

??

import plotly
import plotly.graph_objs as go


values=[14439.6, 650.0, 202.0, 242.0, 206.0, 520.0, 220.0, 120.0, 180.0, 489.6, 129.6, 210.0, 150.0, 12780.0, 5410.0, 7010.0, 360.0, 862.9000000000001, 456.40000000000003, 85.4, 109.2, 46.9, 84.8, 76.9, 53.2, 406.5, 77.3, 80.5, 42.7, 79.3, 78.2, 48.5, 466.30199999999996, 36.0, 11.7, 12.3, 12.0, 76.1, 26.0, 27.7, 22.4, 49.599999999999994, 16.2, 16.6, 16.8, 28.82, 14.41, 14.41, 38.129999999999995, 13.0, 13.18, 11.95, 31.243000000000002, 10.47, 10.41, 10.363, 40.599999999999994, 14.879999999999999, 13.77, 11.95, 23.459, 11.92, 11.539, 46.43, 16.79, 15.780000000000001, 13.86, 72.86, 22.47, 24.240000000000002, 26.15, 23.06, 11.53, 11.53]
labels=['UK','city2', 'place7', 'place8', 'place9', 'city5','place7', 'place8', 'place9', 'city6', 'place7', 'place8', 'place9', 'city7', 'place7', 'place8', 'place9', 'China', 'city8', 'place5', 'place3', 'place4', 'place1', 'place2', 'place6', 'city9', 'place5', 'place3', 'place4', 'place1', 'place2', 'place6', 'India', 'city1', 'place7', 'place8', 'place9', 'city2', 'place7', 'place8', 'place9', 'city10', 'place7', 'place8', 'place9', 'city11', 'place8', 'place9', 'city12', 'place7', 'place8', 'place9', 'city13', 'place7', 'place8', 'place9', 'city3', 'place7', 'place8', 'place9', 'city4', 'place8', 'place9', 'city14', 'place7', 'place8', 'place9', 'city15', 'place7', 'place8', 'place9', 'city16', 'place8', 'place9']
parents=['', 'UK', 'city2', 'city2', 'city2', 'UK', 'city5', 'city5', 'city5', 'UK', 'city6', 'city6', 'city6', 'UK', 'city7', 'city7', 'city7', '', 'China', 'city8', 'city8', 'city8', 'city8', 'city8', 'city8', 'China', 'city9', 'city9', 'city9', 'city9', 'city9', 'city9', '', 'India', 'city1', 'city1', 'city1', 'India', 'city2', 'city2', 'city2', 'India', 'city10', 'city10', 'city10', 'India', 'city11', 'city11', 'India', 'city12', 'city12', 'city12', 'India', 'city13', 'city13', 'city13', 'India', 'city3', 'city3', 'city3', 'India', 'city4', 'city4', 'India', 'city14', 'city14', 'city14', 'India', 'city15', 'city15', 'city15', 'India', 'city16', 'city16']

labels1=labels[0:17];labels1.extend(labels[32:73])
parents1=parents[0:17];parents1.extend(parents[32:73])
values1=values[0:17];values1.extend(values[32:73])
trace1 = go.Sunburst(
ids=tuple(labels[0:17],),
labels=tuple(labels[0:17],),
parents=tuple(parents[0:17],),
values=tuple(values[0:17],),
domain=dict(column=0),
maxdepth=5
)

trace2 = go.Sunburst(
ids=tuple(labels[17:32],),
labels=tuple(labels[17:32],),
parents=tuple(parents[17:32],),
values=tuple(values[17:32],),
domain=dict(column=0),
maxdepth=5
)

trace3 = go.Sunburst(
ids=tuple(labels[32:73],),
labels=tuple(labels[32:73],),
parents=tuple(parents[32:73],),
values=tuple(values[32:73],),
domain=dict(column=0),
maxdepth=5
)


trace4 = go.Sunburst(
ids=tuple(labels[:32],),
labels=tuple(labels[:32],),
parents=tuple(parents[:32],),
values=tuple(values[:32],),
domain=dict(column=0),
maxdepth=5
)




trace5 = go.Sunburst(
ids=tuple(labels[17:73],),
labels=tuple(labels[17:73],),
parents=tuple(parents[17:73],),
values=tuple(values[17:73],),
domain=dict(column=0),
maxdepth=5
)
trace6 = go.Sunburst(
ids=tuple(labels1,),
labels=tuple(labels1,),
parents=tuple(parents1,),
values=tuple(values1,),
domain=dict(column=0),
maxdepth=5
)
trace7 = go.Sunburst(
ids=tuple(labels2,),
labels=tuple(labels2,),
parents=tuple(parents2,),
values=tuple(values2,),
domain=dict(column=0),
maxdepth=5
)





layout = go.Layout(
grid=go.layout.Grid(columns=2, rows=1),
margin = go.layout.Margin(t=0, l=0, r=0, b=0),
sunburstcolorway=[
"#636efa","#EF553B","#00cc96","#ab63fa","#19d3f3",
"#e763fa", "#FECB52","#FFA15A","#FF6692","#B6E880",
   
  ],
extendsunburstcolors=True
)

data = [trace7]

fig = go.Figure(data, layout)

plotly.offline.plot(fig, filename='large_number_of_slices')


Here i will get the blank screen if i combine the data of all three country (UK ,China ,India)
(you can observer if you modify data as " data = [trace7] "

@nandan-nayak

You get a blank plot because the list pair (parents1, labels1) does not define tree data.
A tree should have only one root (denoted here by ’ ') or listing all pairs:

list(zip(parents1, labels1))

[('', 'UK'),
 ('UK', 'city2'),
 ('city2', 'place7'),
 ('city2', 'place8'),
 ('city2', 'place9'),
 ('UK', 'city5'),
 ('city5', 'place7'),
 ('city5', 'place8'),
 ('city5', 'place9'),
 ('UK', 'city6'),
 ('city6', 'place7'),
 ('city6', 'place8'),
 ('city6', 'place9'),
 ('UK', 'city7'),
 ('city7', 'place7'),
 ('city7', 'place8'),
 ('city7', 'place9'),
 ('', 'India'),
 ('India', 'city1'),
 ('city1', 'place7'),
 ('city1', 'place8'),
 ('city1', 'place9'),
 ('India', 'city2'),
 ('city2', 'place7'),
 ('city2', 'place8'),
 ('city2', 'place9'),
 ('India', 'city10'),
 ('city10', 'place7'),
 ('city10', 'place8'),
 ('city10', 'place9'),
 ('India', 'city11'),
 ('city11', 'place8'),
 ('city11', 'place9'),
 ('India', 'city12'),
 ('city12', 'place7'),
 ('city12', 'place8'),
 ('city12', 'place9'),
 ('India', 'city13'),
 ('city13', 'place7'),
 ('city13', 'place8'),
 ('city13', 'place9'),
 ('India', 'city3'),
 ('city3', 'place7'),
 ('city3', 'place8'),
 ('city3', 'place9'),
 ('India', 'city4'),
 ('city4', 'place8'),
 ('city4', 'place9'),
 ('India', 'city14'),
 ('city14', 'place7'),
 ('city14', 'place8'),
 ('city14', 'place9'),
 ('India', 'city15'),
 ('city15', 'place7'),
 ('city15', 'place8'),
 ('city15', 'place9'),
 ('India', 'city16'),
 ('city16', 'place8')]

we can notice that you have two roots (i.e. two ’ ') in the list parents1.

Here https://plot.ly/python/sunburst-charts/ in the official documentation for "Large number of slices " , the sunburst chart has 2 parents(aromas and tastes)…

And even in my code if you give “data=[trace4]” it will display sunburst chart with two roots (UK,China)
i.e two ‘’

Yes, in that example are concatenated two trees. In this a case try to define your data in trace6 like in the plotly example:

list(zip(list(df1.parents), list(df1.labels)))

[(nan, 'Aromas'),
 (nan, 'Tastes'),
 ('Aromas', 'Enzymatic'),
 ('Aromas', 'Sugar Browning'),
 ('Aromas', 'Dry Distillation'),
 ('Tastes', 'Bitter'),
 ('Tastes', 'Salt'),
 ('Tastes', 'Sweet'),
 ('Tastes', 'Sour')
 ...]

i.e. in the list parents1, give first the two roots, then the level 1 children, level 2, etc, and correspondingly for ids1 and labels1.
Perhaps plotly.js cannot “figure out” how to assign children to their parents from your now longer lists.

1 Like

ok… i got the solution…

we need to give different ids if we have repetitive labels.

thanks…

Hi I’m having a similar issue. My sunburst has repetitive labels on the outer (2nd) layer. I have created a column in the data.frame (in R) to feed into the ids = parameter but I can’t get the it to work. perhaps the format is wrong, but I have followed the format above

Atm I only see one instance of each label on the outer layer, what I need is for the labels to show multiple times on the outer layer.

If I use your plot as an example I would like it to show that city 1 and city 2 have labels for place 1, place 2 and place 3. atm they only show when I click on one of them and the sunburts zooms in

you need to give different ids even if the labels are same . if possible share the values of parents , ids, labels. .values.

Thanks I’ve got it working now

I am having the same problem with the sunburst chart in python. I’ve had even shaped my dataset exactly equal to the site example(Large Number of Slices), but still it doesn’t render.

if you don’t mind upload the whole code so that we can check .

Thanks for helping! But I’ve just solved it… It happens that you can’t have ids with same names than it’s parents.

1 Like

thanks for that hint with the identical ids.

1 Like

Sunburst is one of my favorite plotly tools but I found the way it works to be really confusing with regards to parents, labels, and ids. Perhaps expanding the docs might help. For instance, “If ids is filled, parents items are understood to be “ids” themselves.” is a bit counter intuitive. Why is it that if I provide ids, then the parents are used as ids? What am I missing?

If you have parent child relationship in your data, the child uses parent’s id to recognize it as child, sometimes there may be more number of parents with the same name but the id’s of those parents are different to avoid ambiguity

Thanks - I ended up switching to plotly express and just passing a dataframe with nested columns to avoid having to set patients and ids.