我有一个数据集
data2 = dict(type = 'choropleth',
locations = df3['Code'],
z = df3['Power Consumption KWH'])
layout2 = dict(title = '2014 Global Power Consumption',
geo = dict(showframe = False, projection = {'type': 'natural earth'}))
choromap2 = go.Figure(data = [data2], layout=layout2)
iplot(choromap2)
此后,我创建了一个弧度,但是我的问题是地图没有显示任何颜色,只显示了地球形状。
谢谢!
答案 0 :(得分:0)
我尝试复制您的数据,发现您缺少一个重要参数,即locationmode = "country names"
。添加它应该可以
data2 = dict(type = 'choropleth',
locations = df['Code'],
locationmode = "country names", # add this
z = df['Power Consumption KWH'])
layout2 = dict(title = '2014 Global Power Consumption',
geo = dict(showframe = False, projection = {'type': 'natural earth'}))
choromap2 = go.Figure(data = [data2], layout=layout2)
iplot(choromap2)