2012-06-18 49 views
62

gnuplotを使用してグラフをプロットしようとしています.6つのテキストファイルがあります。各テキストファイルには2つの列が含まれています。シーケンス番号です.6つのファイルすべてに対して、時間とグラフのグラフを1つのグラフにプロットしたいと思います。このファイルを使用しています。私のファイルがあるgnuplot:複数の入力ファイルのデータを1つのグラフにプロットする

set terminal png 
set output 'akamai.png' 

set xdata time 
set timefmt "%S" 
set xlabel "time" 

set autoscale 

set ylabel "highest seq number" 
set format y "%s" 

set title "seq number over time" 
set key reverse Left outside 
set grid 

set style data linespoints 

plot "print_1012720" using 1:2 title "Flow 1", \ 
plot "print_1058167" using 1:2 title "Flow 2", \ 
plot "print_193548" using 1:2 title "Flow 3", \ 
plot "print_401125" using 1:2 title "Flow 4", \ 
plot "print_401275" using 1:2 title "Flow 5", \ 
plot "print_401276" using 1:2 title "Flow 6" 

  • print_1012720
  • print_1058167
  • print_193548
  • print_401125
  • print_401275
  • print_401276

以下のように奇妙なエラーを与えている:未定義の変数:プロット

私が何かをやっていることが可能wrong.Isライン24は、

"plot.plt"同じグラフ内の異なるファイルからの入力データをプロットすることができます。

+0

は は、このトピックに HTTPを行く、賢いう.com/questions/14946530/loop-structure-inside-gnuplot –

答えて

106

あなたはとても近いです!

変更:

plot "print_1012720" using 1:2 title "Flow 1", \ 
plot "print_1058167" using 1:2 title "Flow 2", \ 
plot "print_193548" using 1:2 title "Flow 3", \ 
plot "print_401125" using 1:2 title "Flow 4", \ 
plot "print_401275" using 1:2 title "Flow 5", \ 
plot "print_401276" using 1:2 title "Flow 6" 

へ:

plot "print_1012720" using 1:2 title "Flow 1", \ 
    "print_1058167" using 1:2 title "Flow 2", \ 
    "print_193548" using 1:2 title "Flow 3", \ 
    "print_401125" using 1:2 title "Flow 4", \ 
    "print_401275" using 1:2 title "Flow 5", \ 
    "print_401276" using 1:2 title "Flow 6" 

gnuplotはプロットするファイル名として単語「プロット」を解釈しようとしているため、エラーがあるが、あなたは任意の文字列を割り当てていません変数 "plot"(これは良いです - それは非常に混乱するでしょう)。

57

gnuplotのforループは、ファイル名やグラフのタイトルを適切に調整すると便利です。

filenames = "first second third fourth fifth" 
plot for [file in filenames] file."dat" using 1:2 with lines 

filename(n) = sprintf("file_%d", n) 
plot for [i=1:10] filename(i) using 1:2 with lines 
+5

私はこれを知っています古いものですが、代替ソリューションを追加していただきありがとうございます。 gnuplotのループを認識していなかったので、素晴らしい機能です。 – Amit

+0

通常のファイル名の規則(name.dat)を仮定すると、これはファイル "。dat"でなければなりません。最初 。ファイル名を "dat"に連結しますが、プロットコマンドで実際に使用されたファイル名には含まれません。 – jake

+0

明示的に名前を書かなくても、ファイルをすべて*ディレクトリにプロットすることはできますか? (http:// stackoverflow。com/q/29969393/855050) – becko

14

再プロットは、一度に複数のプロットを取得する別の方法です:// stackoverflowの:

plot file1.data 
replot file2.data 
関連する問題