通过对 time进行排序 进而绘制
'''
Created on 2019年2月19日
@author: hcl
'''
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.dates import datestr2num,DateFormatter
import matplotlib.dates as dates
file_path = 'info_ID 3 2.csv'
msg = pd.read_csv(file_path) # index = False
msg = msg.sort_values('Time')
Y = msg['a_mean']
datess = msg['Time']
fig,ax=plt.subplots()
formatter = DateFormatter('%H')
#设置时间间隔
ax.xaxis.set_major_locator(dates.HourLocator(byhour=range(24), interval=1))
ax.xaxis.set_major_formatter(formatter)
ax.plot_date(datess,Y,'-',label='iops')
plt.show()
输出: