v05 log update 02

This commit is contained in:
13339479676 2022-01-28 12:18:54 +08:00
parent 2ebf49b2e8
commit fb4a7b8fcf
1 changed files with 16 additions and 33 deletions

View File

@ -22,27 +22,21 @@ color_list = ['#f96801']
# 创建折线图
def createLineChart(frames_y, today):
today_date = [] # 日期
today_time = [] # 时间
for i in range(len(today)):
today_date.append(today[i][0]) # 日期
today_time.append(today[i][1]) # 时间
def createLineChart(frames_y, date_list, time_list):
# 画布尺寸
plt.figure(figsize=(8, 4))
# 线型
plt.plot(today_time, frames_y, color=color_list[0], marker='o',
plt.plot(time_list, frames_y, color=color_list[0], marker='o',
label='时间点', markerfacecolor=color_list[0], markersize=5)
# 标签
for a, b in zip(today_time, frames_y):
for a, b in zip(time_list, frames_y):
plt.text(a, b, b, ha='center', va='bottom', fontsize=10.5)
# -----------标题、横纵轴、图例等-----------
plt.title(OWS_VERSION, fontsize=12, fontproperties=TimesNesRoman) # 标题
plt.xlabel(today_date[0], fontsize=12,
plt.xlabel(date_list[0], fontsize=12,
fontproperties=TimesNesRoman) # 横轴,时间
plt.ylabel('帧数', fontsize=12, fontproperties=SimSun) # 纵轴,帧数
@ -53,34 +47,23 @@ def createLineChart(frames_y, today):
plt.savefig('./chart.png', dpi=300, bbox_inches='tight') # 保存图像
# 正则日期
def regularToday(today_list):
date_time = [] # 日期时间列表
for i in range(len(today_list)):
date_ = today_list[i].split(' ')
date_time.append([date_[0], date_[1]]) # 日期-时间二维数组
return date_time
# csv2list
def csv2list(csv_path="../date_time_frames.csv"):
f = open(csv_path, 'r') # 读取csv
f_list = csv.reader(f) # 转成csv
for i in f_list:
print(i)
d_list = [] # 日期列表
t_list = [] # 时间列表
frames_list = [] # 时间列表
for item in f_list:
d_list.append(item[0].split(' ')[0])
t_list.append(item[0].split(' ')[1])
frames_list.append(int(item[1]))
return d_list, t_list, frames_list
if __name__ == '__main__':
y = [1, 4, 9, 16, 35]
today01 = "2022-01-26 10:32:29"
today02 = "2022-01-26 10:32:51"
today03 = "2022-01-26 10:43:48"
today04 = "2022-01-26 10:43:56"
today05 = "2022-01-26 13:53:03"
# createLineChart(x, y, today)
# todayList = [today01, today02, today03, today04, today05]
# date_time_list = regularToday(todayList)
# createLineChart(y, date_time_list)
csv2list()
date_list, time_list, y = csv2list()
createLineChart(y, date_list, time_list)