简体   繁体   English

霍罗珀斯图不着色国家?

[英]Choropleth map not coloring countries?

I asked a question yesteday, but i guess it was a bit too much code or unclear, so i've deleted it and will try to make my question more clear. 昨天我问了一个问题,但是我想这有点太多代码或不清楚,所以我删除了它,并将尝试使我的问题更清楚。

I have a dataframe (df) with all the countries in the world, it looks like this : 我有一个与世界所有国家/地区的数据框(df),它看起来像这样:

Country CountryCode Population
0   Afghanistan AF  30206627.0
1   Åland Islands   AX  NaN
2   Albania AL  2881160.0
3   Algeria DZ  37812804.0
4   American Samoa  AS  NaN

My choropleth code looks like this: 我的choropleth代码如下所示:

data = dict(type = 'choropleth', 
           locations = df['CountryCode'],
           z = df['Population'],
           text = df['Country'],
           colorbar = dict(title = 'Population'))

layout = dict(title = '2013 global Population', 
             geo = dict(showframe = False,
                       projection = {'type': 'stereographic'}))

choromap = go.Figure(data = [data], layout = layout)

plot(choromap)

When i run my code i get the following result: 当我运行我的代码时,我得到以下结果:

地图

As you can see my population bar is colored correctly, and it takes the correct population values from the dataframe and puts them on the population bar. 如您所见,我的总体条正确着色,并且它从数据框中获取正确的总体值并将其放在总体条上。 So what am i doing wrong here, since i just gives me a blank map, instead of coloring the different countries? 那我在做什么错了,因为我只是给我一张空白的地图,而不是给不同的国家涂色?

Thank you in advance Best regards . 预先感谢您的问候。

我发现,在将我的弦谱图导出到Ploty之后,问题确实是我使用的是ISO-2而不是ISO-3,所以我想我必须找到一种转换代码的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Choropleth 世界地图未显示所有国家 - Choropleth world map not showing all countries folium Choropleth 世界地图:国家的默认值 - folium Choropleth world map: default values for countries 使用 folium 为特定国家/地区绘制世界等值线 map 时出错 - Error plotting world choropleth map for specific countries using folium 如何创建一个下拉菜单来更改用于为等值线 map 着色的列? (情节快报) - How to create a dropdown menu which changes the column used for coloring a choropleth map? (Plotly Express) 是否可以让 Plotly choropleth 使用 ISO 3166-1 alpha-2 国家代码而不是 ISO 3166-1 alpha-3 来映射国家? - Is it possible to make Plotly choropleth use ISO 3166-1 alpha-2 country codes instead of ISO 3166-1 alpha-3 to map countries? 我正在制作带有 plotly express 的等值线图。 如何将 csv 数据框中的值与 geojson 文件中的国家/地区进行匹配? - I'm making a choropleth map with plotly express. How do I match up the values in my csv dataframe with the countries in the geojson file? plotly:突出显示/识别 choropleth 中的某些国家/地区 - plotly: Highlight / identify certain countries in choropleth Plotly choropleth 显示美国而不是其他国家的颜色 - Plotly choropleth shows color for US and not other countries 等值线图未显示 - choropleth map not showing 悉尼的等值线地图 - Choropleth Map of Sydney
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM