matplotlib折线图使用

import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

y_array = [14488, 10993, 8862, 7379, 6088, 5227, 4599, 4046, 3634, 3446, 3188, 3029, 2921, 2782, 2795, 3027, 3310, 3890, 4663, 5994, 7895, 10180, 14426, 22019, 30899, 41684, 52664, 66324, 84432, 101829, 124655, 157705, 187930, 217870, 205279, 224452, 177829, 163814, 145167, 143455]
x_array = [‘00:15’, ‘00:30’, ‘00:45’, ‘01:00’, ‘01:15’, ‘01:30’, ‘01:45’, ‘02:00’, ‘02:15’, ‘02:30’, ‘02:45’, ‘03:00’, ‘03:15’, ‘03:30’, ‘03:45’, ‘04:00’, ‘04:15’, ‘04:30’, ‘04:45’, ‘05:00’, ‘05:15’, ‘05:30’, ‘05:45’, ‘06:00’, ‘06:15’, ‘06:30’, ‘06:45’, ‘07:00’, ‘07:15’, ‘07:30’, ‘07:45’, ‘08:00’, ‘08:15’, ‘08:30’, ‘08:45’, ‘09:00’, ‘09:15’, ‘09:30’, ‘09:45’, ‘10:00’]

plt.figure(figsize=(27, 7), dpi=40)#图片大小
plt.rcParams[‘font.family’] = [‘sans-serif’]#中文显示
plt.rcParams[‘font.sans-serif’] = [‘SimHei’]#中文显示
plt.plot(x_array , y_array, c=‘red’,lw=‘5’)#折线图
plt.tick_params(axis=‘y’,labelsize=17)
plt.tick_params(axis=‘x’,labelsize=13)#x坐标大小
plt.grid(axis=‘y’, linestyle=‘–’, alpha=1)#Y轴,虚线—
ax=plt.gca()
ax.yaxis.set_major_locator(ticker.MultipleLocator(25000))#y轴间隔
ax.yaxis.set_minor_locator(ticker.MultipleLocator(5000))#y轴小格间隔
ax.spines[‘right’].set_color(‘none’)#去除右框
ax.spines[‘top’].set_color(‘none’)
ax.spines[‘left’].set_color(‘none’)
plt.savefig(“./xrd.png”)
plt.show()
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值