我有一个熊猫数据框架:
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'发布于 2018-07-05 13:10:18
从您的问题中,我了解到您希望在同一张图上有一个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)https://stackoverflow.com/questions/51176040
复制相似问题