import datetime
import matplotlib.pyplot as plt
import pylab as mpl
import numpy as np
#数据源
list_date=['20191005','20191014','20191021','20191217',
'20200125','20200331','20200407','20200904',
'20200913','20200927','20201027','20201029',
'20201205','20201207','20201214','20210106',
'20210115','20210214','20210228','20210307',
'20210314','20210406','20210908','20211107']
list_count=[-26.88,-30.07,-17.81,-8.52,-4.32,
-25.83,-30.66,-34.48,-37.69,-28.82,
-12.38,-22.38,-20.20,-6.33,-3.75,
-7.61,-3.57,-10.89,-10.03,-11.66,
-18.71,-19.33,-25.02,-13.14]
mpl.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus'] = False
fig=plt.figure(figsize=(8,3))
ax=fig.add_subplot(111)
plt.xlabel('日期')
plt.ylabel('温度/℃')
xs = [datetime.datetime.strptime(d, '%Y%m%d').date() for d in list_date]
#x坐标的刻度值
ar_xticks = np.arange(1, len(list_date)+1, step=1)
plt.xticks(ar_xticks, list_date, rotation=45, fontsize=10)
plt.yticks(np.arange(-36, 0, step=10), fontsize=10)
ax.plot(ar_xticks, list_count, color='r')
标签:10,plt,python,list,xticks,date,ar,折线图,绘制 From: https://www.cnblogs.com/joyspace/p/17072899.html