From c3fffb2d1082eb9f8eff64b27670c47a66a7b58e Mon Sep 17 00:00:00 2001 From: 13339479676 Date: Thu, 27 Jan 2022 16:59:11 +0800 Subject: [PATCH] fonts opt update 03 --- utils/plot.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/utils/plot.py b/utils/plot.py index 7a2ed55..4f80a77 100644 --- a/utils/plot.py +++ b/utils/plot.py @@ -13,14 +13,25 @@ SimSun = font_manager.FontProperties(fname="./fonts/SimSun.ttc", size=12) TimesNesRoman = font_manager.FontProperties( fname="./fonts/TimesNewRoman.ttf", size=12) - -def create_chart(x, y, today): +# 创建折线图 +def createLineChart(x, y, today): # x, y为两个list - plt.plot(x, y, color='r', marker='o') # 线型 + plt.plot(x, y, color='r', marker='o', label='时间点') # 线型 # plt.axis([0, 6, 0, 20]) - plt.title('OpenCV Webcam Script v0.5', fontproperties=TimesNesRoman) # 标题 + plt.title(f'OpenCV Webcam Script v0.5 {today}', + fontproperties=TimesNesRoman) # 标题 plt.xlabel(today, fontproperties=TimesNesRoman) # 横轴,时间 - plt.ylabel('帧数', fontproperties=TimesNesRoman) # 纵轴,帧数 + plt.ylabel('帧数', fontproperties=SimSun) # 纵轴,帧数 - plt.savefig('test.png', dpi=100, bbox_inches='tight') # 保存图像 + plt.xticks(fontproperties=TimesNesRoman) # 横轴刻度 + plt.yticks(fontproperties=TimesNesRoman) # 纵轴刻度 + plt.legend(prop=SimSun) # 图例 + + plt.savefig('./chart.png', dpi=300, bbox_inches='tight') # 保存图像 # plt.show() + + +if __name__ == '__main__': + x = [1, 2, 3, 4] + y = [1, 4, 9, 16] + createLineChart(x, y, "abc")