Matplotlib (Python) 發表於 2022-11-11 更新於 2022-11-14 分類於 Coding Disqus: 文章字數: 501 所需閱讀時間 ≈ 1 分鐘 Pyplot 123456789101112131415161718192021import datetimeimport matplotlib.pyplot as pltdef twDateToGlobal(twDate): year, month, date = twDate.split("/") print(datetime.date(int(year), int(month), int(date)) ) return datetime.date(int(year), int(month), int(date))def Chart(): cmd = "SELECT * FROM stockPrice" cursor.execute(cmd) rows = cursor.fetchall() x = [twDateToGlobal(row[0]) for row in rows] # 日期 y = [row[2] for row in rows] # 股價 plt.plot_date(x, y, 'g') plt.xticks(rotation=70) plt.show()Chart() RefMatplotlib Tutorial