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

如何拼接gnuplot数据块?循环拼接$Data报错解决

Gnuplot数据块拼接实现方法

你遇到的报错是因为gnuplot中数据块(以$开头的变量)不能像普通字符串那样用.运算符直接拼接,$Temp = $Temp . $Data这种写法不符合数据块的操作规则,才会抛出data block name must be followed by << EODmarker错误。

要实现数据块的循环拼接,正确的做法是利用set table的append模式,每次将临时数据块$Data的内容追加到目标数据块$Temp中,具体代码如下:

# 先初始化空的目标数据块$Temp
set table $Temp
plot NaN with table  # 生成无数据的空数据块
unset table

do for [selected_label in LABELS] {
    # 生成当前循环的临时数据$Data
    set table $Data  
    plot '' index group using (@sel):(@corrected_volume) with table
    unset table
    
    # 将$Data的内容追加到$Temp
    set table $Temp append
    plot $Data using 1:2 with table
    unset table
}

# 输出拼接后的结果
print $Temp

关键说明:

  • set table $Temp append会开启数据块的追加模式,后续的plot命令会把数据追加到$Temp末尾,而不是覆盖原有内容
  • 初始化$Temp时用plot NaN with table是为了创建一个合法的空数据块,避免第一次追加时出错

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 23:23:07