[英]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.