初探matplotlib

本文通过实例演示了如何使用Python的Matplotlib库绘制并分析单帧耗时的折线图,包括设置字体、坐标轴标签、标题、刻度、填充选项、网格、保存及显示图表。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

from matplotlib import pyplot

font = {
    'family' : 'SimHei',
    'weight' : 'bold',
    'size'   : '16'}
pyplot.rc('font', **font)


frameTime = [120, 220, 350, 270, 380, 500, 540]
frame = [i for i in range(1, len(frameTime)+1)]
#  生成图表
pyplot.plot(frame, frameTime)
# 设置横坐标为帧号,纵坐标为检测耗时,标题为单帧耗时分析
pyplot.xlabel('帧号')
pyplot.ylabel('检测耗时')
pyplot.title('单帧耗时分析(ms)')
# 设置纵坐标刻度
pyplot.yticks([i for i in range(100, 900, 50)])
pyplot.xticks([i+1 for i in range(0, len(frameTime), 1)])
# 设置填充选项:参数分别对应横坐标,纵坐标,纵坐标填充起始值,填充颜色(可以有更多选项)
# pyplot.fill_between(year, people, 10, color = 'green')
# 显示网格
pyplot.grid(True, linestyle="--", color="gray", linewidth="1", axis='both')
# 保存图片
pyplot.savefig(r"d:\test.png")
# 显示图表
pyplot.show()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值