我正在尝试使用创建分区统计图plotly.express
当图形加载时,它仅显示一种颜色(色标的底部)并显示单个区域的轮廓。这显然意味着它正在读取 geojson 但无法正确显示。
My df
看起来像这样:
NUTS level nuts318cd ... 2016.0 2017
5 NUTS3 UKC11 ... 4457.0 4569.0
6 NUTS3 UKC12 ... 4092.0 4137.0
7 NUTS3 UKC13 ... 1692.0 1697.0
8 NUTS3 UKC14 ... 7913.0 8088.0
10 NUTS3 UKC21 ... 5872.0 6015.0
.. ... ... ... ... ...
230 NUTS3 UKN12 ... 2256.0 2310.0
231 NUTS3 UKN13 ... 2263.0 2287.0
232 NUTS3 UKN14 ... 2555.0 2578.0
我的代码是:
import plotly.express as px
fig = px.choropleth(data_frame=df, geojson=spatial, locations='nuts318cd',
featureidkey='properties.nuts318cd', color='2017',
scope='europe'
)
fig.update_geos(showcountries=False, showcoastlines=True,
showland=False, fitbounds="locations")
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
如果需要,该项目的所有数据都可以免费复制。
如果有人理解,将不胜感激。
图形输出:
我怀疑您遇到了 GeoJSON 中多边形“缠绕”的问题:https://github.com/plotly/plotly.py/issues/2354#issuecomment-638742767 https://github.com/plotly/plotly.py/issues/2354#issuecomment-638742767
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)