parent
6ee10adff4
commit
bf41fa1ae2
@ -0,0 +1,22 @@
|
||||
# 代码8-1
|
||||
import pandas as pd
|
||||
import os
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
plt.figure(figsize=(8, 4))
|
||||
file_list = os.listdir("../data/time")
|
||||
for file_name in file_list:
|
||||
if file_name.split(".")[-1] == "csv":
|
||||
df_time = pd.read_csv("../data/time/" + file_name)
|
||||
plt.plot(df_time["date"], df_time["num"], label=file_name)
|
||||
|
||||
plt.xticks([5, 10, 15, 20], ['5:00', '10:00', '15:00', '20:00'])
|
||||
plt.yticks([0, 100000, 200000, 300000, 400000, 500000, 600000],
|
||||
['0', '10', '20', '30', '40', '50', '60'])
|
||||
plt.rcParams['font.sans-serif'] = 'SimHei' # 设置字体为SimHei显示中文
|
||||
plt.xlabel('时间点') # fontproperties参数可以显示相应字体
|
||||
plt.ylabel('刷卡人数(单位:万)')
|
||||
plt.title('图例')
|
||||
plt.legend(("2014-06-09", "2014-06-10", "2014-06-11", "2014-06-12", "2014-06-13"), loc=1)
|
||||
plt.show()
|
||||
Loading…
Reference in new issue