Sunburst branchvalues parameter

I’m struggling to use the sunburst graph object in a Jupyter notebook. It’s perfect for my use case (spread of file formats in a given corpus), however using the parameter branchvalues=‘total’ gives me just a white box.
A dodgy workaround setting the parent values to 0 gives me this:


which is how it should look. I’ve rechecked my data several times, the combined value of children adds up foreach parent.

trace = go.Sunburst(
    labels=sun.index,
    parents=sun['parent'],
    values=sun['count'],
    #branchvalues='total',
    outsidetextfont = {"size": 20, "color": "#377eb8"},
    marker = {"line": {"width": 2}},
)
layout = go.Layout(
    margin = go.layout.Margin(t=0, l=0, r=0, b=0, )
)
iplot(go.Figure([trace], layout), filename='format_spread')
1 Like

I’m having this same issue, all of the value add up to their parents and so on! were you able to solve this? I would greatly appreciate any help

The only thing I can think of is that my values are floats and that’s making an issue

The idea behind branchvalues is that for a sunburst like the one above, you either externally calculate the values for every sector and use total OR you specify the value of all leaves and set the branch values to 0 and use remainder.

The more interesting case is if you ever have a parent whose width is not fully accounted for by its children. In this case you either specify the total value of the parent or the “remainder” value of the parent i.e. the additional width of the parent, over and above that of the children.

Hope that helps!

Unfortunately I was never able to rectify it, I checked repeatedly the values of parents and children and could not work out where the issue was. My values are integers, so using floats is probably not your issue.

Hi Nicholas,

For the above plot, the values for each parent were calculated externally and the children values added to the total of each parent, hence my confusion. Setting branch values to 0 is a poor solution as I’d like to know the totals for branch and leaf values.

Ah I see. I would love to see an example of this with numbers so I can track it down! It definitely seems like a bug with total mode.

For remainder mode, when you say you want to “know” the values, do you mean when you hover over the sectors? This is possible via hovertemplate I believe, if not in 1.49.x, in the 1.50.x version of plotly.js which was just released, and should be available in the soon-to-come plotly.py 4.2 :slight_smile:

For example, this works as expected:

import plotly.graph_objects as go

go.Figure(go.Sunburst(
    parents=["","a","a","b"],
    labels=["a", "b", "c", "d"],
    values=[2,1,1,1],
    branchvalues="total"
))

I’d share the data with you, but I removed the figure as I just couldn’t get it to work! Their is potentially something I’m missing, but I can’t see it. If I have a chance I’ll try and recreate it, as it is a very neat way of visualising these sort of stats.
Yes the hover worked, but if I have to set branch values to , then of course this is not an accurate figure.

Capture1 Capture2 Capture

Pic 1 is what the sunburst looks like, pic 2 is how I would like it to look.

This is the data that I’m using, I’ve manually added up all the values and they add up exactly to the value of their parent. I’ve also tried the workaround mentioned above by setting the root value to zero.

I don’t understand why the visualization will only work with branchvalues = remainder.
I have made a smaller dummy data to test to plot a sunburst with branchvalues=total (the 2nd picture) and that works fine

Have you found a solution to this problem? I am having a similar issue. I want the wedges to be evenly distributed with respect to the size of the parent. When using branchvalues=‘total’ on a small test dataset this works perfectly. But when I use large dataset I get a blank plot.

This seems like a bug, so any help in reproducing it would go a long way towards a fix :slight_smile:

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online