如何使用颜色图在X轴上设置时间范围和在Y轴上设置日期范围

时间:2019-03-12 09:39:43

标签: python pandas matplotlib

我创建了一个代码,该代码显示CSV文件中数据的热图。 代码如下:

import pandas as pd
import matplotlib.pyplot as plt
data= pd.read_csv("data.csv" , sep=';', header=0, 
index_col='Date')
fig=plt.imshow(data, cmap='YlOrBr', interpolation='nearest')
plt.colorbar()
plt.xlabel("Time (UTC)")
plt.ylabel("Date")
plt.show()

enter image description here

数据集如下:

enter image description here

时间范围从00:00到23:50,以10分钟为步长。 我希望x轴以小时为单位显示从00:00到23:50的时间。

索引设置为日期。日期范围是从2017年10月29日到2018年3月24日。 我希望Y轴以月为单位显示日期范围。

0 个答案:

没有答案
相关问题