Changing default color palette in Plotly Go? Python, Sunburst

Iā€™m constructing a series of sunburst graphs using plotly.go.Sunburst and would like to change to a different discrete color scheme. The documentation makes this seem easy when using plotly express (default plotly palette is px.colors.qualitative.Plotly), but there is no information on how to change to a different custom color palette/swatch using go.Sunburst since it lacks a color_discrete_sequence= argument.

Does anyone know how I can change the default color palette? The inputs and categories vary based on end-user choices in the dashboard iā€™m building, so hard-coding color handling would be a huge pain in the ass. If I can just feed in an array of hex or rgb values to replace the default Plotly palette that would be ideal.

Though not the solution I had hoped for, there is a work-around using the library to establish a custom layout theme. (reference documentation)

Example code:

import as pio

# naming a layout theme for future reference
pio.templates["google"] = go.layout.Template(
    layout_colorway=['#4285F4', '#DB4437', '#F4B400', '#0F9D58',
                     '#185ABC', '#B31412', '#EA8600', '#137333',
                     '#d2e3fc', '#ceead6']

# setting Google color palette as default
pio.templates.default = "google"
1 Like

For me using plotly 5.3.1 in Python this worked

import as pio
pio.templates[pio.templates.default].layout.colorway = ['#465dc2','#ad45ed','#ed4545','#ffa436']

to modify the default template, whatever it is, on the fly. Note that I used layout.colorway instead of layout_colorway.