from matplotlib import pyplot as plt
plt.figure(figsize=(12,8))
import matplotlib
font = {
‘family’:‘SimHei’,
‘weight’:‘bold’,
‘size’:12
}
matplotlib.rc(“font”, **font)
tem = [15,13,14.5,17,20,25,26,26,27,22,18,15]
temp = [f’{i}度’ for i in range(min(tem),max(tem)+1)]
t = [2i for i in range(0,12)]#表示数值
t1 = [f’{2i}h’ for i in range(0,12)]#表示刻度
t1
plt.xticks(t,t1,rotation=40)
plt.yticks(range(min(tem),max(tem)+1),temp)
plt.plot(t,tem,color=‘purple’,marker=‘o’)
plt.title(‘一天中每隔两个小时的气温变化’,color=‘r’)
plt.xlabel(‘时间’,color=‘purple’)
plt.ylabel(‘温度’,color=‘purple’)
plt.grid()
plt.show()