這可能是類似於此problem但礦是plot_date的上下文中。轉換s到H:在matplotlib(data_plot)在y軸米
UPDATE
log = row[3]
day = log.strftime("%Y%m%d")
month = log.strftime("%m")
month2 = log.strftime("%B")
year = log.strftime("%y")
times = to_seconds(log.strftime("%I:%M"))
log
是從2016-10-28 20:53:26
格式的數據庫記錄。
time3 =[29100.0, 28860.0, 29280.0, 37980.0, 29100.0, 24780.0, 29700.0, 29160.0, 29460.0, 29100.0, 28980.0, 33780.0, 29400.0, 29100.0, 29400.0, 30360.0, 6180.0, 28860.0, 29400.0, 4440.0, 29160.0, 29160.0]
day3 = ['20161003', '20161004', '20161005', '20161006', '20161007', '20161009', '20161010', '20161011', '20161012', '20161013', '20161014', '20161017', '20161018', '20161019', '20161020', '20161021', '20161023', '20161024', '20161025', '20161026', '20161027', '20161028']
plt.grid(True, which='both')
plt.grid(b=True, which='major', color='k', linestyle='-')
plt.grid(b=True, which='minor', color='k', linestyle='-', linewidth=0.1)
plt.xticks(rotation='vertical',fontsize='small')
plt.minorticks_on()
plt.margins(0.01)
plt.plot_date(x=day3,y=time3,color="red", linestyle='--', markersize=4)
plt.ylabel("Time")
plt.xlabel("Day")
附
是樣本輸出:
我想要顯示的y軸在H:米格式。
[Python的時間秒至h:M:S]的可能的複製(http://stackoverflow.com/questions/775049/python-time-seconds-to-hms) – Jalo
燦你詳細說明Jalo。謝謝。 – user1693411
好的。但我需要更多有關你的代碼,因爲我無法重現你的情節,爲了增加改進 – Jalo