plot update

This commit is contained in:
13339479676 2022-01-27 19:29:26 +08:00
parent b9d9191ede
commit fbb6ad313e
1 changed files with 23 additions and 13 deletions

View File

@ -3,7 +3,6 @@
# 创建时间2022-01-27
import os
import matplotlib.pyplot as plt
from matplotlib import font_manager
@ -15,28 +14,39 @@ TimesNesRoman = font_manager.FontProperties(
# 创建折线图
def createLineChart(x, y, today):
today_list = today.split(' ')
today_date, today_time = today_list[0], today_list[1]
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]) # 时间
plt.plot(x, y, color='r', marker='o', label='时间点') # 线型
plt.plot(today_time, frames_y, color='r', marker='o', label='时间点') # 线型
# plt.axis([0, 6, 0, 20])
plt.title(f'OpenCV Webcam Script v0.5',
fontproperties=TimesNesRoman) # 标题
plt.xlabel(today_date, fontproperties=TimesNesRoman) # 横轴,时间
plt.xlabel(today_date[0], fontproperties=TimesNesRoman) # 横轴,时间
plt.ylabel('帧数', fontproperties=SimSun) # 纵轴,帧数
plt.xticks(fontproperties=TimesNesRoman) # 横轴刻度
plt.yticks(fontproperties=TimesNesRoman) # 纵轴刻度
plt.xticks(fontproperties=TimesNesRoman, rotation=45) # 横轴刻度
plt.yticks(fontproperties=TimesNesRoman, rotation=45) # 纵轴刻度
plt.legend(prop=SimSun) # 图例
plt.savefig('./chart.png', dpi=300, bbox_inches='tight') # 保存图像
# plt.show()
# 正则日期
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
if __name__ == '__main__':
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
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"
@ -45,5 +55,5 @@ if __name__ == '__main__':
# createLineChart(x, y, today)
todayList = [today01, today02, today03, today04, today05]
print(todayList)
date_time_list = regularToday(todayList)
createLineChart(y, date_time_list)