dictionary - Plotly express 或 Go - 地图县内的标签
问题描述
我正在尝试根据“更改”或“县”项目在瓷砖上贴标签,如下所示。我无法实现它。下面是我的示例代码。
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 方法以及其他论坛上答案中显示的建议,看起来它仅适用于图形工厂,因为 scatter 方法仅适用于那个。
任何帮助将不胜感激。
解决方案
我在这里找到了答案: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')
推荐阅读
- python - 当用户输入数字时,它应该得到扩展
- python - 带有代理的 Python 请求导致 SSLError WRONG_VERSION_NUMBER
- git - CI/CD 中的拉取请求和合并操作
- heroku - 尝试运行不和谐机器人时出现错误“node_modules check into source control”
- javascript - 如何从服务器获取的数据中保存和写入可执行文件?
- python - Python中的正态伽马分布
- pandas - YFinance 上的 Pandas 数据框
- r - 将插值模型数据列添加到 r 中的字段数据集
- python - 在 url 中传递 id 以获取对象信息
- python - 在 tox 中运行 awk