如何使用gnuplot绘制文件包含许多列和列标题 [英] how to plot file contains many columns and column header using gnuplot
本文介绍了如何使用gnuplot绘制文件包含许多列和列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些这样的数据文件:
I have some data file like this:
Id a1 a2 a3
1 1 2 3
2 2 3 4
3 2 3 4
但是我不知道确切的列数,但是我可以使用shell将其放入变量中.我想绘制数据文件,在一张图片中将第一列作为x轴,将其他列作为y轴,并将列标题作为line的标题.
But I don't know the exact number of column, but I can get it into variable with shell. And I want to plot the data file, the first column as the x-axis and the others as the y-axis in one picture and the column header as the title for line.like this:
如何在gnuplot中绘制?非常感谢
How to plot in gnuplot? Many thanks
推荐答案
请考虑以下示例
colhead.gp :
plot for [i=2:n+1] 'colhead.dat' u 1:i w lp title columnheader(i)
colhead.dat :
Id a1 a2 a3
1 1 2 3
2 2 3 4
3 2 3 4
要从外壳获取参数:
gnuplot -persist -e "n=4" colhead.gp
这篇关于如何使用gnuplot绘制文件包含许多列和列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文