2013-12-22 53 views
1

我有表的文件繪製的曲線,在文件中的每個列對應於一個曲線gnuplot的情節在文件

例如,文件1

N plot1 plot2 plot3 

1 2  3  4 
2 3  4  5 

我運行gnuplot的如下

gnuplot -e "set key autotitle columnhead; set title 'file1'; plot 'file1' using 1:2 with lines, 'file1' using 1:3 with lines, 'file1' using 1:4 with lines"

問題是如果我有很多曲線繪圖,我有很多列我需要在gnuplot的命令中描述它們,但是我認爲它是pret TY標準繪製與第一列每列文件,像1:2 1:3 1:4

我能做到這一點更方便的方式,而不列出所有列?使用for循環

回答

1

這是可以做到,例如

plot for [i=2:4] "file" using 1:i 

對於此功能,您需要一個至少爲4.4的Gnuplot版本。

+0

非常感謝你的回答,你知道怎麼做是通用的,例如,如果我有少於4條曲線或4個以上? – user16168

+0

@ user16168我真的不知道該怎麼做。 – Bernhard

+1

您需要一個外部工具來計算列數。嘗試'MAXCOL = INT(系統( '頭-1' .file '| awk的 「{打印NF}」'))'。 – Christoph