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 中国大陆许可协议进行许可。

posted @   MoonOut  阅读(83)  评论(0编辑  收藏  举报
历史上的今天:
2022-05-26 事件驱动优化:概念、模型与重要性
2022-05-26 概述:基于事件的优化方法 / 事件驱动优化 / Event-Based Optimization / EBO
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 Sibelius: Violin Concerto in D Minor, Op. 47:III. Allegro, ma non tanto Jascha Heifetz / Chicago Symphony Orchestra
Sibelius: Violin Concerto in D Minor, Op. 47:III. Allegro, ma non tanto - Jascha Heifetz / Chicago Symphony Orchestra
00:00 / 00:00
An audio error has occurred.