当我为多个变量调用时,我很难创建一个绘制热图的函数。
这是我到目前为止所做的工作,效果非常好,但我怎样才能将它变成一个函数呢?
df = pd.DataFrame(columns=['ypos', 'xpos', 'val'])
df.loc[0] = [1,1,MD.at[0,"VarName[1][1]"]]
df.loc[1] = [1,2,MD.at[0,"VarName[1][2]"]]
df.loc[2] = [1,3,MD.at[0,"VarName[1][3]"]]
df.loc[3] = [1,4,MD.at[0,"VarName[1][4]"]]
df.loc[4] = [2,1,MD.at[0,"VarName[2][1]"]]
df.loc[5] = [2,2,MD.at[0,"VarName[2][2]"]]
df.loc[6] = [2,3,MD.at[0,"VarName[2][3]"]]
df.loc[7] = [2,4,MD.at[0,"VarName[2][4]"]]
df.loc[8] = [3,1,MD.at[0,"VarName[3][1]"]]
df.loc[9] = [3,2,MD.at[0,"VarName[3][2]"]]
df.loc[10] = [3,3,MD.at[0,"VarName[3][3]"]]
df.loc[11] = [3,4,MD.at[0,"VarName[3][4]"]]
df.loc[12] = [4,1,MD.at[0,"VarName[4][1]"]]
df.loc[13] = [4,2,MD.at[0,"VarName[4][2]"]]
df.loc[14] = [4,3,MD.at[0,"VarName[4][3]"]]
df.loc[15] = [4,4,MD.at[0,"VarName[4][4]"]]
print(df)
ax = sns.heatmap(df.pivot('ypos', 'xpos', 'val'), annot=True)
ax.invert_yaxis()
请注意,VarName 1 ... VarName [4] [4]是数据集中每列的标题名称。
我真的很感谢你的帮助!!
答案 0 :(得分:0)
Picasso.with(context)
.load(-yourImgURL-)
.resize(450, 200) // resizes image to desired dimensions here
.into(-yourImageView);
这会输出与上面相同的热图以及标题,但是来自一个函数。