[問題] plotly如何用按鍵切換顏色參數抓取的欄位

看板Python作者 (JJJ)時間5年前 (2020/06/06 08:12), 編輯推噓1(100)
留言1則, 1人參與, 5年前最新討論串1/2 (看更多)
前輩大大們各位好, 以下這兩張圖是我想做出的效果 https://imgur.com/qlrLBqu
https://imgur.com/8AGG340
我用以下的程式碼可以畫出類似的介面 但點擊按鈕無法更新/改變圖表: import plotly.express as px df = px.data.tips() fig = px.scatter(df, x="total_bill", y="tip", color="smoker") ## How to fix this part? fig.update_layout( updatemenus=[ dict( type = "buttons", direction = "left", buttons=list([ dict( args=["color", "sex"], label="sex", method="update" ), dict( args=["color", "smoker"], label="smoker", method="update" )])),]) fig.show() ## 請問該如何修改,或用其他哪種套件能達到我想要的效果? 再請麻煩大大們指教 謝謝各位 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.215.153.241 (香港) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1591402364.A.894.html

06/07 21:54, 5年前 , 1F
我回了一篇有類似效果的文在底下,請參考。
06/07 21:54, 1F
文章代碼(AID): #1UsjzyYK (Python)
文章代碼(AID): #1UsjzyYK (Python)