Gnuplot 如何在一行中绘制多条记录的数据

Gnuplot 如何在一行中绘制多条记录的数据,gnuplot,Gnuplot,我想画JCAMP-DX格式的光谱。 它在一行中有多条y轴记录,并为x轴指定了增量 简单示例:线性图(1,1)到(12,12) 1 12 3 4 5 6 7 8 9 1011112 第一列表示x轴,第二到第四列表示y轴,属于x的每个后续y数据递增一。我可以使用命令进行绘图: 使用带点的1:2线颜色“黑色”绘制“test.gnuplot”,使用($1+1):3线颜色“黑色”绘制“test.gnuplot”,使用($1+2):4线颜色“黑色”绘制“黑色” 然而,光谱要复杂得多,我想用线来绘制它,这不可

我想画JCAMP-DX格式的光谱。 它在一行中有多条y轴记录,并为x轴指定了增量

简单示例:线性图(1,1)到(12,12)
1 12 3
4 5 6
7 8 9
1011112

第一列表示x轴,第二到第四列表示y轴,属于x的每个后续y数据递增一。我可以使用命令进行绘图:
使用带点的1:2线颜色“黑色”绘制“test.gnuplot”,使用($1+1):3线颜色“黑色”绘制“test.gnuplot”,使用($1+2):4线颜色“黑色”绘制“黑色”

然而,光谱要复杂得多,我想用线来绘制它,这不可能使用上述方法(线不会连接,并且会在绘图的非线性区域产生丑陋的交点)。
现在我只绘制第二列(
使用1:2
),但这会降低分辨率。
我希望避免使用外部过滤器(awk等)和编辑输入文件(vim等)


真实数据(跳过前35行——数据规范):

您希望避免使用外部工具,但可能可以使用gnuplot本身创建临时文件

我从webbook.nist.gov获取了真实数据,删除了注释行和最后一行数据,该行的y值小于其他行

我的建议是:

datafile = "7664-41-7-IR.jdx2"
dx = 0.935253
col_count=6

# Build a function that will create a new datafile by converting
# single lines of the form "x y1 y2 y3 ..." into multiple
# lines of the form "x y1", "x+dx  y2", "x+2*dx y3", ...
#  
# We will call this function later for each input line and append
# the new data values.

all_command = "all = sprintf(\"%s"
do for [i=2:col_count] {
   all_command = all_command."%f %f\n"
}
all_command = all_command."\", all"
do for [t=2:col_count] {
   all_command = all_command.", column(1)+dx*(".t."-2), column(".t.")"
} 
all_command = all_command.")"

# Just to check: 
print all_command

# Now we call the function for each input line. The variable "all" will contain
# the "expanded" data. Note, the "plot" command is a dummy plot.
all = ""
plot datafile using 1:( @all_command, 1)

# Generate the temporary data file
set print "temp_file.dat"
print all

plot datafile w p, "temp_file.dat" w l
这是输出的一部分:


一般情况下,如果要计算行数,请检查

您希望避免使用外部工具,但是否可以使用gnuplot本身创建临时文件

我从webbook.nist.gov获取了真实数据,删除了注释行和最后一行数据,该行的y值小于其他行

我的建议是:

datafile = "7664-41-7-IR.jdx2"
dx = 0.935253
col_count=6

# Build a function that will create a new datafile by converting
# single lines of the form "x y1 y2 y3 ..." into multiple
# lines of the form "x y1", "x+dx  y2", "x+2*dx y3", ...
#  
# We will call this function later for each input line and append
# the new data values.

all_command = "all = sprintf(\"%s"
do for [i=2:col_count] {
   all_command = all_command."%f %f\n"
}
all_command = all_command."\", all"
do for [t=2:col_count] {
   all_command = all_command.", column(1)+dx*(".t."-2), column(".t.")"
} 
all_command = all_command.")"

# Just to check: 
print all_command

# Now we call the function for each input line. The variable "all" will contain
# the "expanded" data. Note, the "plot" command is a dummy plot.
all = ""
plot datafile using 1:( @all_command, 1)

# Generate the temporary data file
set print "temp_file.dat"
print all

plot datafile w p, "temp_file.dat" w l
这是输出的一部分:

一般情况下,如果要计算行数,请检查