我使用 plotly 的 choropleth 制作了一張包含特定資料的世界地圖。對于某些國家/地區,我缺少值,這給了我無色區域,尤其是無法識別它們。
編輯: 我發現如何通過在“update_layout”的“geo=dict()”中添加這個來為缺失值的國家著色:
landcolor = 'lightgray',
showland = True,
showcountries = True,
countrycolor = 'gray',
countrywidth = 0.5,
這給出了這個代碼:
import plotly.graph_objects as go
fig = go.Figure(data = go.Choropleth(
locations = world_map_df_sous_nutrition["Code zone (ISO3)"],
z = round((world_map_df_sous_nutrition["Proportion pop en sous-nutrition"]),2),
text = world_map_df_sous_nutrition["Zone"],
colorscale = "earth",
autocolorscale = False,
reversescale = True,
marker_line_color = "white",
marker_line_width = .2,
colorbar_tickprefix = "%",
colorbar_title = "Proportion de personnes en sous nutrition"
))
fig.update_layout(
title_text="L'état de la sous-nutrition dans le monde en 2017",
geo=dict(
landcolor = 'lightgray',
showland = True,
showcountries = True,
countrycolor = 'gray',
countrywidth = 0.5,
showframe=False,
showcoastlines=False,
projection_type='equirectangular'
),
annotations = [dict(
x=0.55,
y=0.1,
xref='paper',
yref='paper',
text='Source: <a href="https://www.fao.org/faostat/fr/#data">\
FAO</a>',
showarrow = False
)],
margin={"r":0,"t":0,"l":0,"b":0},
)
fig.show()
這個影像結果:

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/417367.html
標籤:
上一篇:為什么SwiftUI不透明影片在Gesture的onEnded方法中失敗?
下一篇:如何僅獲取陣列中的文本?
