Whenever I make a Plotly sunburst chart (I'm using Python) the outermost 'circle' or ring is is much lighter than the rest of the sunburst rings. How can I have the shade of this ring be the same as the rest of the chart?
As you can see, the segment labeled Bb5 is lighter than the rest.
I am using standard Plotly sunburst code. Simple example (will be lighter shade anyway):
import plotly.graph_objects as go
fig =go.Figure(go.Sunburst(
labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
parents=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
values=[10, 14, 12, 10, 2, 6, 6, 4, 4],
))
# Update layout for tight margin
# See https://plotly.com/python/creating-and-updating-figures/
fig.update_layout(margin = dict(t=0, l=0, r=0, b=0))
fig.show()
You're looking for:
leaf=dict(opacity=1)
This sets the opacity of the leaves. With a specified colorscale it is defaulted to 1
, otherwise it is defaulted to 0.7
.
Plot 1: leaf=dict(opacity=1)
Now, compare this to:
Plot 2: leaf=None
Now, the opacity defaults to 0.7
And take a look at what happens when you've specified a value for colorscale
:
Plot 3: colorscale='RdBu'
If you leave out the leaf argument, the figure defaults to opacity = 1 for the leaves:
And lastly, you can have it both ways with colorscale
and leaf=dict(opacity=0.2)
. I'm just setting opacity very low here to make a clear point:
Here's the complete code for the case you were looking for:
import plotly.graph_objects as go
fig =go.Figure(go.Sunburst(
labels=["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
parents=["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ],
values=[10, 14, 12, 10, 2, 6, 6, 4, 4],
leaf=dict(opacity=1),
#marker=dict(colorscale='RdBu')
))
fig.update_layout(margin = dict(t=0, l=0, r=0, b=0))
fig.show()