我正在尝试使用差异对象创建一个绘图热图,例如,它将是一些技术性KPI。我想使用一种颜色的调色板,但是我的对象(obj1,obj2,obj3)需要具有不同的颜色范围。
例如:
对象1: (100-97]绿色/ (97-90]黄色/ (90-0)红色
对象2: (0-1]绿色/ (1-3]黄色/ (3-100)红色
Object3: (100-97]绿色/ (97-90]黄色/ (90-0)红色
感谢您的帮助或建议。
df=pd.DataFrame({"obj": ['Object1','Object1','Object1','Object1','Object1',
'Object2','Object2','Object2','Object2','Object2',
'Object3','Object3','Object3','Object3','Object3'],
"date":[pd.Timestamp('20200101'),pd.Timestamp('20200102'),pd.Timestamp('20200103'),pd.Timestamp('20200104'),pd.Timestamp('20200105'),
pd.Timestamp('20200101'),pd.Timestamp('20200102'),pd.Timestamp('20200103'),pd.Timestamp('20200104'),pd.Timestamp('20200105'),
pd.Timestamp('20200101'),pd.Timestamp('20200102'),pd.Timestamp('20200103'),pd.Timestamp('20200104'),pd.Timestamp('20200105')],
"values": [100,97,80,100,100,0,0,10,2,0,150,120,100,25,170]})
data = [go.Heatmap(x=df['date'], y=df['obj'], z=df['values'], colorscale='RdYlGn')]
layout = go.Layout(title = 'Heatmap test')
fig = go.Figure(data = data, layout=layout)
fig.show()
我想要什么: every object have different color range values scheme