[英]Python seaborn heatmap
I'm doing a heatmap.我正在做一个热图。 I have a list of list in this format我有一个这种格式的列表
[ [x1,y1,value1], [x2,y2,value2]... ] [ [x1,y1,value1], [x2,y2,value2]... ]
I have done a Dataframe like following:我做了一个 Dataframe ,如下所示:
X Y VEL
0 -4.799990 1.599996 93.294099
1 11.199978 -1.599996 97.714788
2 -14.399973 -1.599996 131.289188
3 4.799990 4.799995 118.418184
4 4.799988 -4.799995 91.098021
5 -4.799988 -1.599996 91.177642
6 -1.599996 4.799989 85.077989
7 4.799989 1.600002 67.702695
8 1.599995 -1.600002 110.756954
9 -1.599995 -4.799989 112.697441
I want to put in 2D axis with seaborn putting on them vel我想把seaborn放在二维轴上
I have this code.我有这个代码。 list is in the format that I have told before.列表是我之前告诉过的格式。 pd is pandas library sb is seaborn library pd 是 pandas 库 sb 是 seaborn 库
df = pd.DataFrame(list, columns=["X", "Y", "VELOCIDAD"])
df = df.head(10)
print(df)
data_extract = pd.pivot_table(df, values='VELOCIDAD',
index='X',
columns='Y')
plt.show(sb.heatmap(data_extract,cmap="YlGnBu"))
I get the following graphic: Result我得到以下图形:结果
Thanks in advance.提前致谢。
if you want 'Vel' values to be put on them try: plt.show(sb.heatmap(data_extract,cmap="YlGnBu", annot=True))
如果您希望将“Vel”值放在上面,请尝试: plt.show(sb.heatmap(data_extract,cmap="YlGnBu", annot=True))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.