1 回答

TA貢獻(xiàn)1863條經(jīng)驗 獲得超2個贊
使用您的數(shù)據(jù)嘗試以下代碼:(
我嘗試將您的變量放在正確的位置)
choropleth = go.Choropleth(
locations=temp['state_code'],
locationmode='USA-states',
z = temp['num_proposals'].astype(float),
zmin = 0,
zmax = max(temp['num_proposals'].astype(float)),
colorscale=scl,
autocolorscale=False,
text='Proposals',
marker_line_color='white',
colorbar_title="% Acceptance Rate"
)
fig = go.Figure(data=choropleth)
fig.update_layout(
title_text='Project Proposals % of Acceptance Rate by US States',
geo = dict(
scope='usa',
projection=go.layout.geo.Projection(type = 'albers usa'),
showlakes=True,
lakecolor='rgb(255, 255, 255)'),
)
fig.show()
此代碼的工作原理是使用您的數(shù)據(jù)創(chuàng)建 Plotly Choropleth 圖形對象,然后將該對象加載到 Plotly Figure Graph 對象中,然后更新布局(以獲得正確的標(biāo)題和縮放),最后顯示圖形。
添加回答
舉報