【发布时间】:2021-08-31 11:39:36
【问题描述】:
使用当前代码,我得到了悬停工具提示,但是这些在 PNG 导出中不可见。我需要在每个多边形上都有静态标签。
import plotly.express as px
df = px.data.election()
geojson = px.data.election_geojson()
fig = px.choropleth_mapbox(df, geojson=geojson, color="Bergeron",
locations="district", featureidkey="properties.district",
center={"lat": 45.5517, "lon": -73.7073},
mapbox_style="carto-positron", zoom=9)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
我发现的解决方案不起作用,它们仅适用于choropleth,但不适用于我想使用的choropleth_mapbox。他们的名单:
https://community.plotly.com/t/labels-inside-counties-for-a-map/13953
https://community.plotly.com/t/annotations-on-plotly-choropleth/36219
https://community.plotly.com/t/how-can-i-change-the-hover-labels-into-static-labels/4690/2
【问题讨论】:
标签: python charts plotly plotly-python choropleth