Gnuplot从列标题(从文件)设置x y标签

Gnuplot从列标题(从文件)设置x y标签,plot,gnuplot,Plot,Gnuplot,考虑到数据(在文件中,test.txt): 如果我这样做: set key autotitle columnheader plot "test.txt" using 1:2 然后我得到: 如果我这样做了: set xlabel "x(volts)" set ylabel "y(amp)" plot "test.txt" using 1:2 然后我得到 在第一种情况下,我从文件中读取标签,但它进入了图例中。在第二种情况下,我设置了xy标签,但没有从文件中读取 如何设置从文件读取的x y

考虑到数据(在文件中,
test.txt
):

如果我这样做:

set key autotitle columnheader
plot "test.txt" using 1:2 
然后我得到:

如果我这样做了:

set xlabel "x(volts)"
set ylabel "y(amp)"
plot "test.txt" using 1:2 
然后我得到

在第一种情况下,我从文件中读取标签,但它进入了图例中。在第二种情况下,我设置了xy标签,但没有从文件中读取


如何设置从文件读取的x y标签?

您可以使用
system
命令将外部程序的输出转换为变量

s=system('head -n 1 test.txt')
set xlabel word(s,2)
set ylabel word(s,3)
plot 'test.txt' u 1:2
s=system('head -n 1 test.txt')
set xlabel word(s,2)
set ylabel word(s,3)
plot 'test.txt' u 1:2