1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
| import matplotlib.pyplot as plt
import random
x = range(50)
weather = [random.uniform(20, 25) for i in x]
weather2 = [random.uniform(23, 30) for i in x]
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(20, 10), dpi=100)
axes[0].plot(x, weather, label="weather")
axes[1].plot(x, weather2, label="weather2")
x_ticks_label = [f"11:{i}" for i in x]
y_ticks = range(40)
axes[0].set_xticks(x[::5])
axes[0].set_yticks(y_ticks[::5])
axes[0].set_xticklabels(x_ticks_label[::5])
axes[1].set_xticks(x[::5])
axes[1].set_yticks(y_ticks[::5])
axes[1].set_xticklabels(x_ticks_label[::5])
axes[0].grid(True, linestyle="--", alpha=0.5)
axes[1].grid(True, linestyle="--", alpha=0.5)
axes[0].set_xlabel("time")
axes[0].set_ylabel("weather")
axes[1].set_xlabel("time")
axes[1].set_ylabel("weather")
axes[0].legend(loc=0)
axes[1].legend(loc=0)
plt.show()
|