python绘制折线图

1 示例代码

代码:

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(1,11,1)
y_1 = np.array([0.7,0.7,0.75,0.77,0.78,0.78,0.78,0.78,0.78,0.78])
y_2 = np.array([0.8,0.8 ,0.8, 0.82, 0.85, 0.86, 0.87, 0.87, 0.87, 0.87])
y_3 = np.array([0.9, 0.94, 0.95, 0.95, 0.98, 0.98, 0.99, 0.99, 0.99, 0.99])
y_4 = np.array([0.93, 0.93, 0.94, 0.94, 0.96, 0.96, 0.97, 0.97, 0.97, 0.97])
y_5 = np.array([0.8, 0.85, 0.85, 0.87, 0.87, 0.87, 0.89, 0.89, 0.89, 0.89])

plt.plot(x,y_1,'-dg',label='-dg')
plt.plot(x,y_2,'--oc',label='--oc')
plt.plot(x,y_3,':^r',label=':^r')
plt.plot(x,y_4,'-.b',label=':b')
plt.plot(x,y_5,':y',label=':y')
# 将图例放在外面
plt.legend(bbox_to_anchor=(1, 0), loc=3, borderaxespad=0)

plt.xlabel('x')
plt.xticks(x)

plt.ylabel('accuracy')

plt.title("The multi-plot of lines ")

plt.show()

2 示例结果

结果:
在这里插入图片描述

3 参考链接

  1. Python_matplotlib画图时图例说明(legend)放到图像外侧
  2. python+matplotlib绘图线条类型和颜色选择
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值