python · matplotlib | 如何绘制子图
代码:
import matplotlib.pyplot as plt import matplotlib matplotlib.rc("font",family='MicroSoft YaHei',weight="bold") fig, axs = plt.subplots(2, 2, figsize=(15,12)) colors = ['blue', 'orange', 'green', 'red'] for i, value in enumerate(item_indexes.values()): temp_p, temp_t = pred[:, value].reshape(-1), test_y[:, value].reshape(-1) # 注释: temp_p temp_t 都是 torch.tensor axs[i//2, i%2].scatter(temp_p, temp_t, c=colors[i], s=20) axs[i//2, i%2].plot([min(temp_t), max(temp_t)], [min(temp_t), max(temp_t)], c='black') axs[0, 0].set_title('空调送风温度', fontsize=14) axs[0, 1].set_title('空调回风温度', fontsize=14) axs[1, 0].set_title('IT 设备进风口温度', fontsize=14) axs[1, 1].set_title('IT 设备出风口温度', fontsize=14) for ax in axs.flat: ax.set(xlabel='真实值', ylabel='预测值') # Hide x labels and tick labels for top plots and y ticks for right plots. for ax in axs.flat: ax.label_outer()
效果:

本文作者:MoonOut
本文链接:https://www.cnblogs.com/moonout/p/17434172.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2022-05-26 事件驱动优化:概念、模型与重要性
2022-05-26 概述:基于事件的优化方法 / 事件驱动优化 / Event-Based Optimization / EBO