How to show the right color on the inner layer of a plotly sunburst?

67 Views Asked by At

I have made a plotly sunburst plot. As you can see in the pictures the layer which is outside has the right color (Value of the outside layer 32k). The inside layer shows the sum of all outer layers (Value ~ 64k) when you hover the mouse over it but is colored for a value of 16k. Here an example code of the figure i made. The total_value is given with about 120k.

from pandas import DataFrame
import plotly.express as px

A = ["a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"]
B = ["b11", "b12", "b21", "b22", "b31", "b32", "b11", "b12", "b21", "b22", "b31", "b32"]
C = ["c111", "c112", "c121", "c122", "c211", "c212", "c221", "c222", "c311", "c312", "c321", "c322"]
C_values = [1, 2, 3, 4, 2, 3, 1, 2, 3, 4, 2, 3]
df = DataFrame(dict(A=A, B=B, C=C, C_values=C_values))

fig = px.sunburst(df, path=["A", "B", "C"], values="C_values", color="C_values", color_continuous_scale=[(0, "green"), (0.5, "yellow"), (1, "red")], range_color=(0, 15))
fig.show()

Plotly sunburst Values of the inner layer Color map

So i would expect the inner layer to be colored in yellow, as 64k is pretty much in the middle of the color scale. Does anyone know why it is not using the some of all values and how this could be fixed?

Edit: I change the example code to a reproducible example and added the plot as a picture. Here the most inner layer "a" has a value of 10, therefore it should be orange. enter image description here

0

There are 0 best solutions below