Changing the background colour of a Graph

Hi @andra.popescu,

The plot_bgcolor is not updated for sunburst because fig.layout.plot_bgcolor='some_color_code' doesn’t work for a fig containing a sunburst.

I checked it with your example:

import plotly.graph_objs as go
fig = go.Figure()
fig.add_traces(go.Sunburst(
            ids=['North America', 'Europe', 'Australia', 'North America - Football', 'Soccer', 
                 'North America - Rugby', 'Europe - Football', 'Rugby'],
            labels=['North America', 'Europe', 'Australia', 'Football', 'Soccer',
                    'Rugby', 'Football', 'Rugby'],
            parents=['', '', '', 'North America', 'North America', 'North America', 'Europe', 'Europe'],
            values=[100, 100, 100, 33, 34, 33, 40, 20],
            outsidetextfont={'size': 20, 'color': '#377eb8'},
            leaf={'opacity': 0.4},
            marker={'line': {'width': 2}},
        ))
    
fig.update_layout(width=450, height=450, plot_bgcolor='rgb(10,10,10)')
fig.show()

The resulting figure has a white background although by my settings it should be black (almost black):

sunburst-plot_bgcolor

I ask @etienne to tell us whether this is a plotly.js issue or a sunburst was devised to accept only white plot_bgcolor.

2 Likes