【问题标题】:Plotly Map not showing绘图地图未显示
【发布时间】:2017-11-19 22:16:54
【问题描述】:

正如您在此处看到的https://www.kaggle.com/asindico/exploratory-analysis 我正在尝试通过 plotly 绘制世界地图,但未显示地图。任何建议将不胜感激

这是相关的代码块

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 笔记本

【问题讨论】:

    标签: python pandas jupyter-notebook plotly


    【解决方案1】:

    您是否添加了该行:

    init_notebook_mode(connected = True)
    

    你需要这条线在 jupyter notebook 中显示图表。

    【讨论】:

      猜你喜欢
      • 2019-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多