Bug in icicle/sunburst charts: marker_colorscale has no effect

Hi there,

In the example below: If you set color changing the colorscale has no effect. If color is not set in px.icicle the colorscale is set as intended.

This is in contradiction to the documentation.

fig = px.icicle(
    names=  ["L0", "L1.1", "L1.2"],
    parents=[  "",   "L0",   "L0"],
    values= [   0,      5,     10],
    # color=  [  10,      2,      4], 
    branchvalues="remainder",
)
fig.update_layout(margin = dict(t=5, l=5, r=5, b=5))
fig.update_traces(marker_colorscale=[[0, 'rgb(0,0,0)'], [1, 'rgb(200,200,200)']], selector=dict(type='icicle'))
fig.update_traces(marker_cmin=0, selector=dict(type='icicle'))
fig.update_traces(marker_cmax=2, selector=dict(type='icicle'))

fig.show()

A fix for this seems to set the numeric marker colors separately via:

fig.update_traces(marker_colors=[10, 2, 4], selector=dict(type='icicle')) 

I also observed the same bug in sunburst charts. range_color (see plotly express documentation) also as inconsistent effects.

It’s also not possible to modify the transition duration:

fig.update_layout(transition_duration=4000)
fig.update_layout(transition = {'duration': 4000})

Is there any way to deactivate transitions apart from misusing uniformtext for that purpose?

Many thanks in advance,
Christoph

Tested with plotly version 5.10.

@gochristoph
To get an icicle or sunburst with color values mapped to the right colorscale, you should update the colorscale and cmin, cmax, via layout colorsaxis:

import plotly.express as px
fig = px.icicle(
    names=  ["L0", "L1.1", "L1.2"],
    parents=[  "",   "L0",   "L0"],
    values= [   0,      5,     10],
    color=  [  10,      2,      4], 
    branchvalues="remainder",
)
fig.update_layout(width=600, height=300, margin = dict(t=5, l=5, r=5, b=5),
                 coloraxis =dict(colorscale= "turbo", cmin=2, cmax=12))
1 Like