![](/img/trans.png)
[英]ModuleNotFoundError: No module named 'plotly.graph_objects'
[英]How to control the color input of a Sunburst with plotly.graph_objects?
我想在下面的森伯斯特圖中控制每個 label 的 colors - 當使用plotly.graph_objects而不是Z2626C5922054DCA時
請參閱以下文檔中的示例:
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=[ 65, 14, 12, 10, 2, 6, 6, 4, 4],
branchvalues="total",
))
fig.update_layout(margin = dict(t=0, l=0, r=0, b=0))
fig.show()
這將允許訪問和控制標記:
import plotly.express as px
greys = px.colors.sequential.Greys
reds = px.colors.sequential.Reds
blues = px.colors.sequential.Blues
greens = px.colors.sequential.Greens
magents = px.colors.sequential.Magenta
fig.data[0].marker.colors = ['', greys[5], reds[5], reds[6], reds[7],
blues[5], greens[5], greens[6], magents[5]]
fig.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.