[英]How to plot a chart with text variables using plotly dash
我有一個看起來像這樣的 df:
我的目標是制作一個折線圖來匯總每個月的代碼,然后添加一個下拉列表,以便能夠在“類型”、“組”和“規格”之間進行過濾。
如果我不想要下拉過濾器,我可以用
`df.groupby('month')['code'].count().reset_index()`
由於我需要過濾器,理想情況是能夠在 plotly 中的圖形代碼中執行此求和,這樣我就不會丟失“類型”、組和“規格”。 列。
我試過這段代碼:
`line_fig1 = px.line(data_frame = df,
x= 'month',
y='code',
labels={'month':'','code':''},
title='',
width=450,
height=250,
template='plotly_white',
color_discrete_sequence= ["rgb(1, 27, 105)"],
markers=True,
text='code'
)`
這是結果:
我也嘗試過類似的東西
`line_fig1 = px.line(data_frame = df,
x= 'month',
y='code'.count()`
甚至嘗試添加一個數字為一的列,這樣圖表就可以聚合
`df['assign_value'] = 1
line_fig1 = px.line(data_frame = df,
x= 'month',
y='assign_value'`
但這也行不通。
這里有什么幫助嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.