Gnuplot-plot for-第一行作为标签

Gnuplot-plot for-第一行作为标签,gnuplot,Gnuplot,gnuplot版本:5.4 我有以下格式的数据集: Label1 Label2 Label3 1 2 3 2 5 6 我想对命令使用plot,因为列的数量不是静态的,我想使用数据集的第一行作为标签 当我使用: 使用($1):($i)和线轴x1y1为[i=2:dataset_列]“dataset.dat”绘图 错误: warning: bad data on line 1 of file dataset.dat Column number or datablock line expected

gnuplot版本:5.4

我有以下格式的数据集:

Label1 Label2 Label3
1 2 3 
2 5 6
我想对命令使用plot,因为列的数量不是静态的,我想使用数据集的第一行作为标签

当我使用:
使用($1):($i)和线轴x1y1为[i=2:dataset_列]“dataset.dat”绘图

错误:

warning: bad data on line 1 of file dataset.dat
Column number or datablock line expected
问题: 如何编辑我的命令以打印数据,如何使用第一行作为标签


谢谢您的帮助。

在gnuplot控制台中检查
的帮助绘图。如果你读到最后,你会看到:

如果要继续迭代,直到消耗所有可用数据, 使用符号*而不是整数。这可以用来 处理一行中的所有列、所有数据集(由2个空格分隔) 行),或与模板匹配的所有文件

示例:

  plot for [i=2:*] 'datafile' using 1:i with histogram
  splot for [i=0:*] 'datafile' index i using 1:2:3 with lines 
  plot for [i=1:*] file=sprintf("File_%03d.dat",i) file using 2 title file
代码:

### plot all columns until last column
reset session

$Data <<EOD
Label1 Label2 Label3
1 2 3 
2 5 6
EOD

plot for [col=2:*] $Data u 1:col w l title columnhead
### end of code
### plot all columns until last column
reset session

plot for [col=2:*] 'datafile.dat' u 1:col w l title columnhead
### end of code
代码:

### plot all columns until last column
reset session

$Data <<EOD
Label1 Label2 Label3
1 2 3 
2 5 6
EOD

plot for [col=2:*] $Data u 1:col w l title columnhead
### end of code
### plot all columns until last column
reset session

plot for [col=2:*] 'datafile.dat' u 1:col w l title columnhead
### end of code
结果:

### plot all columns until last column
reset session

$Data <<EOD
Label1 Label2 Label3
1 2 3 
2 5 6
EOD

plot for [col=2:*] $Data u 1:col w l title columnhead
### end of code
### plot all columns until last column
reset session

plot for [col=2:*] 'datafile.dat' u 1:col w l title columnhead
### end of code

在gnuplot控制台中检查
的帮助绘图。如果你读到最后,你会看到:

如果要继续迭代,直到消耗所有可用数据, 使用符号*而不是整数。这可以用来 处理一行中的所有列、所有数据集(由2个空格分隔) 行),或与模板匹配的所有文件

示例:

  plot for [i=2:*] 'datafile' using 1:i with histogram
  splot for [i=0:*] 'datafile' index i using 1:2:3 with lines 
  plot for [i=1:*] file=sprintf("File_%03d.dat",i) file using 2 title file
代码:

### plot all columns until last column
reset session

$Data <<EOD
Label1 Label2 Label3
1 2 3 
2 5 6
EOD

plot for [col=2:*] $Data u 1:col w l title columnhead
### end of code
### plot all columns until last column
reset session

plot for [col=2:*] 'datafile.dat' u 1:col w l title columnhead
### end of code
代码:

### plot all columns until last column
reset session

$Data <<EOD
Label1 Label2 Label3
1 2 3 
2 5 6
EOD

plot for [col=2:*] $Data u 1:col w l title columnhead
### end of code
### plot all columns until last column
reset session

plot for [col=2:*] 'datafile.dat' u 1:col w l title columnhead
### end of code
结果:

### plot all columns until last column
reset session

$Data <<EOD
Label1 Label2 Label3
1 2 3 
2 5 6
EOD

plot for [col=2:*] $Data u 1:col w l title columnhead
### end of code
### plot all columns until last column
reset session

plot for [col=2:*] 'datafile.dat' u 1:col w l title columnhead
### end of code

仍然不工作,并且出现相同的错误,我有一个文件“dataset.dat”,其数据集类型与我发送的数据集类型相同。在脚本中,我有命令:
使用($1):($I)绘制[I=2:storage\u columns]dataset.dat,其中行轴为x1y1 title columnhead
我的代码是复制和粘贴代码。应该没有错误。然后,您的文件或设置有一些特殊之处。你在使用Linux吗?如何从gnuplot控制台启动脚本?请尝试:
plot for[i=2:storage\u columns]'dataset.dat'u 1:i w l title columnhead
它运行在gnuplot:5.4版本的RHEL上。我有一个包含所有命令的脚本,然后我用命令运行我的脚本,比如
gnuplot-e datasets='dataset.dat dataset2.dat'script.plt
,并将输出保存到svg。Ok so
使用($1):I和行轴x1y1 title columnhead(
正确,感谢您的帮助:)仍然无法工作,并且出现相同的错误,我有一个文件“dataset.dat”,其数据集类型与我发送的数据集类型相同。在脚本中,我有命令:
使用($1):($I)绘制[I=2:storage\u columns]dataset.dat,其中行轴为x1y1 title columnhead
我的代码是复制和粘贴代码。应该没有错误。然后,您的文件或设置有一些特殊之处。你在使用Linux吗?如何从gnuplot控制台启动脚本?请尝试:
plot for[i=2:storage\u columns]'dataset.dat'u 1:i w l title columnhead
它运行在gnuplot:5.4版本的RHEL上。我有所有命令的脚本,然后我用命令运行脚本,比如
gnuplot-e datasets='dataset.dat dataset2.dat'script.plt
,并将输出保存到svg。Ok so
plot for[I=2:storage\u columns]dataset.dat使用($1):I with line axes x1y1 title columnhead
正确,感谢您的帮助:)