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

Gnuplot中columnhead与image(colormaps)搭配失效问题求助

解决Gnuplot颜色映射图添加Time列标题的问题

问题原因

with image要求数据是规则矩形网格结构(x、y需构成均匀网格,每个网格点对应一个Temperature值)。当你在plot命令中直接使用title columnhead(4)时,Gnuplot会错误解析数据读取逻辑,破坏网格数据结构,导致图像重叠、出现"Image data corruption"警告。而set style data points是散点模式,对数据结构要求宽松,因此能正常显示标题,但不符合颜色映射图的需求。

解决方案

下面提供两种可靠的实现方式,既保留颜色映射图,又能显示Time列的表头作为标题/标签:

方法1:提取表头后单独设置标题

用stats命令先读取第4列的表头并存储为变量,再通过set title设置标题,避免干扰with image的数据解析:

# 读取第4列的表头,存入变量title_str
stats filein index 0 using (title_str=stringcolumnhead(4)) nooutput
# 设置图像标题
set title title_str font ",12"
# 绘制颜色映射图
plot filein index 0 using ($1):($2):($3) notitle with image

方法2:用标签替代标题(灵活放置)

如果不想用顶部标题,可将Time表头作为标签放在图像角落(比如右上角),不占用标题区域:

# 读取第4列的表头,存入变量time_label
stats filein index 0 using (time_label=stringcolumnhead(4)) nooutput
# 设置标签位置(右上角,右对齐)
set label 1 time_label at graph 0.95, graph 0.95 right font ",10"
# 绘制颜色映射图
plot filein index 0 using ($1):($2):($3) notitle with image

补充:固定表头场景

如果Time列的表头是固定字符串(比如"Time: 15:30"),可直接手动设置标题,无需读取数据:

set title "Time: 15:30" font ",12"
plot filein index 0 using ($1):($2):($3) notitle with image

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.21 19:17:15