You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将(200,34)形状的NumPy数组绘制成图像的方法

可视化(200,34)温度时间序列数组的几种实用方案

下面给你三种针对这类数据的可视化方法,直接用Python的matplotlib和seaborn就能实现:

1. 单折线图:全局趋势一览

适合快速查看所有测点随时间的温度变化趋势,代码简单直接:

import numpy as np
import matplotlib.pyplot as plt

# 替换成你的实际数据数组
temp_data = np.random.randn(200,34) * 5 + 25  # 模拟25℃左右带波动的温度数据
time_steps = np.arange(temp_data.shape[0])  # 生成0到199的时间步

plt.figure(figsize=(12,6))
# 直接传入二维数组,matplotlib会自动把每一列绘制成一条折线
plt.plot(time_steps, temp_data)
plt.xlabel('时间步')
plt.ylabel('温度(℃)')
plt.title('各测点温度随时间变化趋势')
# 把图例放在图外避免遮挡
plt.legend([f'测点{i+1}' for i in range(34)], bbox_to_anchor=(1.05, 1), loc='upper left')
plt.tight_layout()
plt.show()

如果觉得图例太挤,可以只标注重点测点,或者调整图例的字体大小。

2. 热力图:时空分布直观呈现

想一眼看出哪些时间段、哪些测点温度偏高/偏低?用热力图最合适:

import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

temp_data = np.random.randn(200,34) * 5 + 25

plt.figure(figsize=(10,8))
# 转置数组让测点在y轴、时间在x轴,符合阅读习惯
sns.heatmap(temp_data.T, cmap='coolwarm', xticklabels=20, yticklabels=5)
plt.xlabel('时间步')
plt.ylabel('测点编号')
plt.title('温度时空分布热力图')
plt.show()

参数xticklabels=20表示每20个时间步显示一个刻度,避免x轴刻度重叠;cmap='coolwarm'是冷暖配色,也可以换成viridis等其他配色。

3. 子图网格:逐个测点细节分析

如果需要仔细观察每个测点的波动细节,用子图网格逐个展示:

import numpy as np
import matplotlib.pyplot as plt

temp_data = np.random.randn(200,34) * 5 + 25
time_steps = np.arange(temp_data.shape[0])

# 创建6行6列的子图(刚好放下34个测点,剩余2个隐藏)
fig, axes = plt.subplots(6,6, figsize=(15,12))
axes = axes.flatten()  # 把二维子图数组转成一维,方便遍历

for i in range(34):
    axes[i].plot(time_steps, temp_data[:,i])
    axes[i].set_title(f'测点{i+1}', fontsize=10)
    axes[i].tick_params(axis='both', labelsize=8)  # 缩小刻度字体避免拥挤

# 隐藏多余的两个空图
for j in range(34, 36):
    axes[j].axis('off')

plt.tight_layout()
plt.show()

你可以根据自己的需求调整子图的行数和列数,比如改成7行5列(35个位置)也可以。

内容的提问来源于stack exchange,提问作者Mahmoud

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 03:40:29