地图不显示

2024-03-29 05:26:45 发布

您现在位置:Python中文网/ 问答频道 /正文

正如你在这里看到的https://www.kaggle.com/asindico/exploratory-analysis我试图通过绘图绘制世界地图,但是地图没有显示出来。如有任何建议,将不胜感激

下面是相关的代码块

w_data = [ dict(
        type = 'choropleth',
        locations = data['Country'].value_counts().index,
        z = data['Country'].value_counts(),
        locationmode = 'country names',
        text = data['Country'].value_counts().index,
        marker = dict(
            line = dict(color = 'rgb(0,0,0)', width = 1)),
            colorbar = dict(tickprefix = '', 
            title = 'World map')
            )
       ]

layout = dict(
    title = 'World map',
    width = 20,
    height = 15,
    geo = dict(
        showframe = False,
        showocean = True,
        oceancolor = 'rgb(0,255,255)',
        projection = dict(
        type = 'orthographic',
            rotation = dict(
                    lon = 60,
                    lat = 10),
        ),
        lonaxis =  dict(
                showgrid = True,
                gridcolor = 'rgb(102, 102, 102)'
            ),
        lataxis = dict(
                showgrid = True,
                gridcolor = 'rgb(102, 102, 102)'
                )
            ),
        )

fig = dict(data=w_data, layout=layout)
py.iplot(fig, validate=False)

它属于一个Jupyter笔记本


Tags: falsetruemapworlddataindextitlevalue