折线图 (单线 + 双线)

#%matplotlib notebook  
import matplotlib.pyplot as plt  #载入绘图库
a=[5,9,3,17,9,3,1,8]
b=[9,3,8,16,3,8,9,1]
c=[9,3,15,9,1,3,9,1]

plt.figure(figsize=(15,10))
plt.plot(
    a,
    

    #线条样式
    color = 'blue',
    linestyle = '-',
    linewidth=2,
    
    #标记样式
    marker='*',
    markerfacecolor='#df448b',
    markersize=10,
    


   
    alpha =0.5 #透明度
)
plt.show()

我们可以继续深入改进一下,例如变换一下形式同时增加一条的数据

import matplotlib.pyplot as plt

plt.rcParams["font.family"] = "KaiTi"
x = ["A", "B", "C", "D", "E", "F", "G"]
highest = [12, 15, 18, 14, 16, 14, 10]
lowest = [6, 4, 8, 12, 10, 9, 7]
plt.ylim(0, 25)
plt.plot(x, highest, "rs--")
plt.plot(x, lowest, "rd--")
for a, b in zip(x, highest):
    plt.text(a, b+1, b, ha='center', va='bottom')
    # 数据显示的横坐标、显示的位置高度、显示的数据值的大小
for a, b in zip(x, lowest):
    plt.text(a, b-2, b, ha='center', va='bottom')
plt.legend()
plt.show()

运行结果如图

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值