from matplotlib import pyplot as plt
fig = plt.figure(figsize=(20,8),dpi=80)
x = range(0,26,2)
y = [15,13,14.5,17,20,25,26,26,27,22,18,15,13]
plt.plot(x,y)
plt.xticks(range(0,25,1))
plt.savefig("./sig_size.png")
plt.show()
效果
2.
from matplotlib import pyplot as plt
import random
plt.rcParams['font.sans-serif'] = ['KaiTi']
plt.rcParams['axes.unicode_minus'] = False
x = range(0,120)
y = [random.randint(20,25)for i in range(120)]
fig = plt.figure(figsize=(20,8),dpi=80)
plt.plot(x,y)
_xtick_labels = ["10点{}分".format(i) for i in range(60)]
_xtick_labels += ["11点{}分".format(i) for i in range(60)]
plt.xticks(list(x)[::3],_xtick_labels[::3],rotation=45)
plt.xlabel("时间")
plt.ylabel("温度 单位(℃)")
plt.title("10点到12点每分钟的气温变化情况")
plt.show()
效果