从Numpy阵列绘制python matplotlib imshow

时间:2019-05-21 16:51:37

标签: python matplotlib seaborn

我在Excel工作表中有以下数据:

Time    Bin1    Bin2    Bin3    Bin4    Bin5
11:27:12    256.1   241.4   237.7   235.8   250.8
11:27:32    255.2   228.9   242.2   237.0   247.0
11:27:51    253.0   254.6   256.8   241.3   230.1
11:28:11    243.8   248.2   246.3   249.4   237.5
11:28:30    254.1   236.7   250.4   248.2   255.9
11:28:50    251.1   252.8   250.9   250.0   237.5
11:29:09    246.1   263.5   261.8   256.6   240.6
11:29:29    276.2   259.2   262.9   257.2   244.0
11:29:49    252.3   272.8   261.2   238.6   258.3
11:30:08    264.7   260.4   255.1   247.4   237.9

使用seaborn,我得到以下情节:

ax=sns.heatmap(xlsxsht1)
plt.show()

工作正常,并在Y轴上正确显示时间。但是图像以正方形像素为单位。我需要插值图像或模糊图像。

使用plt.imshow可以构造插值图像,但前提是我不读“时间”列。

已经在Internet上冲浪,但是找不到任何示例如何正确地将时间列从文件转换为plt.imshow所要求和接受的格式。

1 个答案:

答案 0 :(得分:0)

只需将时间转换为以秒为单位的int,例如 How to convert an H:MM:SS time string to seconds in Python? 我会说它必须在x轴上