# encoding=utf-8
import matplotlib.pyplot as plt
import random
plt.rcParams['font.family'] = ['sans-serif']
plt.rcParams['font.sans-serif'] = ['SimHei']
#使matplotlib中可以使用中文字体
x = range(0, 120)
y = [random.randint(20, 35) for i in range(120)]
plt.figure(figsize=(20, 8), dpi=80)
x_labels = ['10点{0}分'.format(i) for i in range(60)]
x_labels += ['11点{0}分'.format(i) for i in range(60, 120)]
plt.xticks(list(x)[::5], x_labels[::5], rotation=90) # 旋转90度
plt.xlabel('时间')
plt.ylabel('温度(摄氏度)')
plt.title('十点到十二点气温每分钟变化情况')
plt.plot(x, y)
plt.savefig('./weather-time plot.png')