plt.style.use('fivethirtyeight') fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2, figsize = (10,10)) fig.autofmt_xdate(rotation = 45) ax1.plot(dates, features['actual']) ax1.set_xlabel(''); ax1.set_ylabel('Temperature'); ax1.set_title('Max Temp') ax2.plot(dates, features['temp_1']) ax2.set_xlabel(''); ax2.set_ylabel('Temperature'); ax2.set_title('Previous Max Temp') ax3.plot(dates, features['temp_2']) ax3.set_xlabel('Date'); ax3.set_ylabel('Temperature'); ax3.set_title('Two Days Prior Max Temp') ax4.plot(dates, features['friend']) ax4.set_xlabel('Date'); ax4.set_ylabel('Temperature'); ax4.set_title('Friend Estimate') plt.tight_layout(pad=2)
时间: 2023-09-15 12:16:14 浏览: 258
这段代码使用了Matplotlib库来绘制一个包含四个子图的大图。其中,第一个子图展示了实际的最高温度,第二个子图展示了前一天的最高温度,第三个子图展示了两天前的最高温度,第四个子图展示了一个朋友的温度估计值。这些子图都使用了日期作为x轴,并使用不同的颜色和标题来区分它们。fig.autofmt_xdate(rotation = 45)这行代码将日期旋转了45度,以避免日期之间的重叠。plt.tight_layout(pad=2)则是用来调整子图之间的间距,使其更加美观。
阅读全文
相关推荐








