1
我需要用python將文字添加到氣泡圖。我只能得到text屬性,每個數據點取1個值。但是,對於每個數據點,我需要在工具提示中顯示兩個值:其大小和另一個值。我使用一個列表清單,鬆散地基於示例here。Plotly python氣泡圖 - 添加文字
這是我的代碼:
bubbletext = dfenv[['Max_FZ','Argmax_FZ']] # dataframe with the 2 cols I need for text
bubbletext = bubbletext.values.tolist() # puts the df into list of lists
trace1 = Scatter(
x=dfenv['X (ft)'],
y=dfenv['Y (ft)'],
text=bubbletext, # here's the problem
mode='markers',
marker=Marker(
size=dfenv['Max_FZ'],
sizeref= dfenv['Max_FZ'].max()/1e2**2,
sizemode='area'
)
)
data = Data([trace1])
layout = Layout(showlegend=False)
fig = Figure(data=data)#, layout=layout)
plot_url = py.plot(fig, filename='Envelope_MaxBubblechart')