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

Gnuplot脚本set style line参数冗余报错的原因与修复方法

问题:Gnuplot报错“Extraneous arguments to set style line”的原因与修复方法

问题背景

运行以下Gnuplot核心脚本时,弹出错误提示Extraneous arguments to set style line,错误集中在线条样式设置段(原脚本第43-50行):

# set-up
nutc = 1.0 # torque

# legend
set key top right

# 1st x axis
set xlabel 't in d^2/{/Symbol n}'
set format x "%.1f"
set xrange [0.0: 1.0]
set xtics   0.0, 0.5
set mxtics  2

# 1st y axis
set ylabel 'Nu_{/Symbol w}'
set format y "%.1f"
set yrange [-0.2:  3.0]
set ytics   -1.0,  1.0
set mytics   5

# grid lines
set nogrid

# line styles with colours appropriate for colour-blind
set style line 10 lc rgb '#000000' dt 2 lw 1.5 # black
set style line 11 lc rgb '#D55E00' dt 1 lw 1.5 # vermillon
set style line 12 lc rgb '#0072B2' dt 1 lw 1.5 # blue
set style line 13 lc rgb '#009E73' dt 1 lw 1.5 # bluish green
set style line 14 lc rgb '#E69F00' dt 1 lw 1.5 # orange
set style line 15 lc rgb '#56B4E9' dt 1 lw 1.5 # sky blue
set style line 16 lc rgb '#CC79A7' dt 1 lw 1.5 # reddish purple
set style line 17 lc rgb '#F0E442' dt 1 lw 1.5 # yellow 

# main plot
set style data lines
plot nutc t 'solution' ls 10,\
     'torque' u ($1):($2) t 'Inner' ls 11,\
     'torque' u ($1):($3) t 'Outer' ls 12

# convert to pdf (epstopdf comes with e.g. TeXlive)
system('epstopdf '.file)

错误原因

该错误由Gnuplot版本兼容性问题导致:

  • Gnuplot 5.0及更早版本的set style line命令不支持同时使用多个属性的简写参数(如lc、dt、lw),必须使用完整的参数名称。
  • 原脚本中使用的lc(linecolor)、dt(dashtype)、lw(linewidth)都是参数简写,旧版本无法识别这种组合写法,因此报错“多余参数”。

修复方法

方法1:适配旧版本(Gnuplot 5.0及更早)

将所有简写参数替换为完整名称,修改后的线条样式设置段代码如下:

# line styles with colours appropriate for colour-blind
set style line 10 linecolor rgb '#000000' dashtype 2 linewidth 1.5 # black
set style line 11 linecolor rgb '#D55E00' dashtype 1 linewidth 1.5 # vermillon
set style line 12 linecolor rgb '#0072B2' dashtype 1 linewidth 1.5 # blue
set style line 13 linecolor rgb '#009E73' dashtype 1 linewidth 1.5 # bluish green
set style line 14 linecolor rgb '#E69F00' dashtype 1 linewidth 1.5 # orange
set style line 15 linecolor rgb '#56B4E9' dashtype 1 linewidth 1.5 # sky blue
set style line 16 linecolor rgb '#CC79A7' dashtype 1 linewidth 1.5 # reddish purple
set style line 17 linecolor rgb '#F0E442' dashtype 1 linewidth 1.5 # yellow 

方法2:升级Gnuplot版本

如果环境允许,将Gnuplot升级到5.1及以上版本,新版本支持在set style line中同时使用多个简写参数,原脚本无需修改即可正常运行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.05 07:53:20