【问题标题】:plotly.express choropleth only showing some information from geojsonplotly.express choropleth 仅显示来自 geojson 的一些信息
【发布时间】:2023-03-27 04:33:02
【问题描述】:

我正在尝试使用plotly.express 创建一个等值线图。当加载图形时,它仅显示一种颜色(色标的底部)并显示单个区域的轮廓。这显然意味着它正在读取 geojson 但未正确显示。

我的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()

如果需要,此项目的所有数据均可免费复制。

如果有人理解,我们将不胜感激。

图形输出:

【问题讨论】:

  • 请提供完整的代码和数据。谢谢。

标签: python pandas plotly choropleth


【解决方案1】:

我怀疑您遇到了 GeoJSON 中多边形“缠绕”的问题:https://github.com/plotly/plotly.py/issues/2354#issuecomment-638742767

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 2016-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多