matplot同时画两条线,代码示例

效果图:

代码:


import matplotlib.pyplot as plt

migtime = [16.6,16.5,16.9,17.1,17.2,18.1,18.2,18.4,19.4,19.3,20.4,20.3,22,21.7,22]
delay = [108,98,92,83,87,77,85,48,31,58,35,43,36,31,19]


fig,ax = plt.subplots()

plt.xlabel('migration speed (MB/s)')
plt.ylabel('migration time (s); request delay (ms)')

"""set interval for y label"""
yticks = range(10,110,10)
ax.set_yticks(yticks)


"""set min and max value for axes"""
ax.set_ylim([10,110])
ax.set_xlim([58,42])


x = [57,56,55,54,53,52,51,50,49,48,47,46,45,44,43]
plt.plot(x,migtime,"x-",label="migration time")
plt.plot(x,delay,"+-",label="request delay")

"""open the grid"""
plt.grid(True)

plt.legend(bbox_to_anchor=(1.0, 1), loc=1, borderaxespad=0.)

plt.show()



  • 5
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值