我有一个熊猫数据框:
A B C
1 1 0.1
2 3 -0.2
1 2 2
我想用x=A
和y=B
绘制(散布),并将颜色作为C
的值。
所以我尝试了
import cufflinks
df.iplot(kind='heatmap', mode='markers',
y='B', x = 'A',
z = 'C',
filename='cufflinks/simple-heatmap')
我有一个错误:
944 colorscale=[[float(_)/(len(scale)-1),scale[_]] for _ in range(len(scale))]
945 center_scale = kwargs.get('center_scale',None)
--> 946 zmin=z.min()
947 zmax=z.max()
948 if center_scale is not None:
AttributeError: 'list' object has no attribute 'min'
答案 0 :(得分:0)
根据您的问题,我了解到您希望在同一张图中绘制heatmap
和scatter
图,因此下面是一个有效的示例。由于您的问题似乎模棱两可,请提供更多详细信息。
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
import cufflinks as cf
cf.go_offline()
init_notebook_mode(connected=True)
test = df.iplot(kind='heatmap', mode='markers',
y='B', x = 'A',
z = 'C',
filename='cufflinks/simple-heatmap', asFigure=True)
test2 = df.iplot(kind='scatter', y='B', x = 'A', colors=["red", "green", "yellow"], mode="markers+lines", asFigure=True)
test['data'].append(test2['data'][0])
iplot(test)