为什么 gnuplot 省略第一行数据?

问题描述 投票:0回答:1

我编写了以下“tmp.dat”数据文件

\# 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20
\#inFile;cn;mv;nr;nd;nn;fil;sep;m#enn=;m#enn=;n=;i=;aLea1=;rLea1=;amea1=;rmea1=;NbaLea1=;NbrLea1=;Nbamea1=;Nbrmea1=;rrmen3a1=
ex32new_DMLPG_beta3_der1emeno5/fort.501;0;?;?;?;?;0.0110485435;0.0078125;14;11.1540828402;4225;0;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00172
ex32new_DMLPG_beta3_der1emeno5/fort.501;1;0.0165088727;1745;64;0;0.0441941738;0.0078125;42;11.2126074499;1745;1;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00172
ex32new_DMLPG_beta3_der1emeno5/fort.501;2;0.0165088858;1726;64;0;0.0441941738;0.0078125;35;11.2027809965;1726;2;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00272
ex32new_DMLPG_beta3_der1emeno5/fort.501;3;0.0165088801;1724;64;0;0.0441941738;0.0078125;39;11.214037123;1724;3;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00372
ex32new_DMLPG_beta3_der1emeno5/fort.501;4;0.0165088766;1720;64;0;0.0441941738;0.0078125;34;11.1831395349;1720;4;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00472
ex32new_DMLPG_beta3_der1emeno5/fort.501;5;0.0165088776;1718;64;0;0.0441941738;0.0078125;32;11.1850989523;1718;5;0.00898;0.00158;0.00205;0.00204;0.00898;0.00158;0.00205;0.00204;0.00572
ex32new_DMLPG_beta3_der1emeno5/fort.501;6;0.0165088822;1710;64;0;0.0441941738;0.0078125;34;11.216374269;1710;6;0.00898;0.00158;0.00205;0.00205;0.00898;0.00158;0.00205;0.00205;0.00672

我的 gnuplot 脚本

set datafile separator ";"
set datafile missing "?"

set grid

set xlabel "coarsening level"

set ylabel "rrmen3a1"

set xrange [-1:7]
set yrange [*:*]

set terminal pdf color
set output "tmp.pdf"

plot \
"tmp.dat" using 2:21 index 0 with lp title columnheader(1), \

#    EOF

不绘制“第一个”点 (0, 0.00172),仅绘制点 x=1,...,6 有什么提示吗?

gnuplot
1个回答
1
投票

问题在于你的情节

plot "tmp.dat" using 2:21 index 0 with lp title columnheader(1)

这指示 gnuplot 使用您的第一条记录(不包括注释行)作为列标签。所以你的第一个数据行被解释为标题。如果您不想重新格式化数据文件,可以使用相同的头文件绘制一条虚拟曲线,该头文件将充当数据系列标签。类似的东西

plot "tmp.dat" using 2:21       index 0 with lp lt 1 lc rgb 'black' notitle, \
     "tmp.dat" using ($0):(1/0) index 0 with lp lt 1 lc rgb 'black' columnhead(1)

请注意,我们必须手动指定线条样式,以确保关键帧与曲线具有相同的线条样式。

© www.soinside.com 2019 - 2024. All rights reserved.