第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用 graph_objects 子模塊在 plotly sunburst 圖表上設(shè)置顏色?

如何使用 graph_objects 子模塊在 plotly sunburst 圖表上設(shè)置顏色?

陪伴而非守候 2023-06-20 15:18:23
如果我使用 plotly express 子模塊,我可以通過(guò)以下方式創(chuàng)建彩色旭日?qǐng)D:import plotly.express as pxnames = ["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"]parents = ["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve" ]values = [10, 14, 12, 10, 2, 6, 6, 4, 4]color_discrete_sequence = ['#2D5F91', '#FFAA00', '#96BEE6', '#48B7B4', '#E8655F',                           '#819FBD', '#FFCC66', '#C0D8F0', '#91D4D2', '#F1A39F']fig = px.sunburst(    names=names,    parents=parents,    values=values,    color_discrete_sequence = color_discrete_sequence,)fig.show()我想對(duì) plotly 的 graph_objects 做同樣的事情。有沒(méi)有類似的功能?
查看完整描述

1 回答

?
森欄

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超5個(gè)贊

該版本在官方參考graph_objects中可用。

import plotly.graph_objects as go


color_discrete_sequence = ['', '#FFAA00', '#2D5F91','#819FBD','#819FBD','#91D4D2', '#96BEE6', '#C0D8F0','#E8655F','#F1A39F','#48B7B4']


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=\[10, 14, 12, 10, 2, 6, 6, 4, 4\],

? ? marker=dict(colors=color_discrete_sequence)

))

# Update layout for tight margin

# See https://plotly.com/python/creating-and-updating-figures/

fig.update_layout(margin = dict(t=0, l=0, r=0, b=0))


fig.show()

http://img2.sycdn.imooc.com/649152df0001c42305080389.jpg

查看完整回答
反對(duì) 回復(fù) 2023-06-20
  • 1 回答
  • 0 關(guān)注
  • 195 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)