Matplotlib (Python)

Pyplot

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import datetime
import matplotlib.pyplot as plt

def 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()

Ref

Matplotlib Tutorial