我正在尝试基于“CHANGE”或“COUNTY”项目在图 block 上放置标签,如下所示。我无法实现它。下面是我的示例代码。
fig = px.choropleth(stat_data, geojson=geo_json_data, color="CHANGE",
locations="COUNTY", featureidkey="properties.COUNTY",
projection="mercator",
color_continuous_scale=px.colors.diverging.RdYlGn, color_continuous_midpoint=2
)
fig.update_geos(fitbounds="locations", visible=False)
fig.show()
我尝试使用plotlyexpress或go方法并使用answer on other forum上显示的建议看起来它只适用于图形工厂,因为分散方法仅适用于该工厂。
任何帮助将不胜感激。
最佳答案
我在这里找到了答案:https://community.plotly.com/t/annotations-on-plotly-choropleth/36219
fig.add_scattergeo(
geojson=counties,
locations = df['names'],
text = df['values'],
featureidkey="properties.NAME_3",
mode = 'text')
关于dictionary - Plotly Express 或 Go - map 县内的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61177895/