我正在尝试使用Jupyter笔记本绘制热图。我的桌子由10个colomns和很多行组成。第一行是colomns的名称。我正在使用plotly lib。
import plotly.offline as py
import plotly.graph_objs as go
import pandas as pd
import numpy as np
import pickle
import matplotlib
import matplotlib.pyplot as plt
from pandas import ExcelWriter
from pandas import ExcelFile
heatmap = go.Heatmap(
z=dfs.corr(method='pearson').as_matrix(),
x=dfs.columns,
y=dfs.columns,
colorbar=dict(title='Pearson Coefficient'),
)
layoutheat = go.Layout(title="title")
figheat = go.Figure(data=[heatmap], layout=layoutheat)
py.iplot(figheat)
dfs是数据帧。
而不是图形我得到了很多像这样的行:
'\ n \ trace = dict(\ nx = x,y = y,z = z,\ n type =“scatter3d”,\ n mode = \'markers \',\ n marker = dict(size = 5,color = \'black \',line = dict(width = 0)))\ ndata = [trace] \ n \ nlayout = dict(\ n etc
有什么问题?
答案 0 :(得分:1)
如果您正在运行jupyter笔记本,则需要在导入后添加py.init_notebook_mode()
。如果它仍然无效,我建议重新安装