首页 > 解决方案 > Plotly 热图与 Jupyter 笔记本不兼容?

问题描述

我对 Plotly 有疑问。首先我的代码:

data=go.Heatmap(z=z, x=df[numerical].columns.values, y=df[numerical].columns.values, 
                type='heatmap', colorscale = 'Viridis', reversescale = False)

layout = go.Layout(title='Pearson Correlation of numerical features',
                   xaxis = dict(ticks='', nticks=36),
                   yaxis = dict(ticks='' ),
                   width = 900, height = 900)


fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='labelled-heatmap')

这段代码在我的 kaggle notebook 中运行没有任何问题。如果我将此代码导入我的 jupyter 笔记本。我收到以下错误:

 Invalid property specified for object of type plotly.graph_objs.Heatmap: 'type'

当我删除类型属性时,出现以下错误:

 Invalid value of type 'plotly.graph_objs._heatmap.Heatmap' received for the 'data' property of 
    Received value

由于我对编程很陌生,我希望这个问题对你来说并不愚蠢。但是你知道a)为什么相同的代码在kaggle notebook中运行没有任何问题,但是jupyter有问题,b)我能做些什么来解决这个问题?

标签: pythonpython-3.xjupyter-notebookplotlykaggle

解决方案


kaggle 和笔记本电脑上的 Plotly 版本可能不匹配。

请通过以下方式更新笔记本电脑上的版本:

pip install -U plotly

推荐阅读