4

gnuplot で次のようなプロットを作成したい:

ここに画像の説明を入力

一定の時点でさまざまなデータ ポイントがあります。これらのデータ ポイントを表す x 値をグループ化します。これらのデータポイントは、次のようなさまざまなデータ ファイルから取得されます。

9 0.333
9 0.308
9 0.289
15 0.356
15 0.836
15 0.364
15 0.347
0 0.386
0 0.318
0 0.347
0 0.322
12 0.351
12 0.314
12 0.314

現在、次のようなループを使用してデータをプロットします。

set xtics (0, 3, 6, 9, 12, 15, 18, 21)
plot for [i=1:15] sprintf('file_%i.dat', i) using 1:2 with points

しかし、それらは重なっています。gnuplot を使用してこれを行うにはどうすればよいですか?

4

1 に答える 1

2

次のように、ポイントのセットごとに手動でオフセットを設定する必要があるでしょう。

#!/usr/bin/env gnuplot

o1 = 0.1 # x-offset for each set of points on plot
n = 15   # number of files, integer
# x-offset for leftmost set of points.
# this will center all sets of points around the central x value,
# whether there are an even or odd number of sets
o2 = (n/2.0 - 0.5) * o1

set xtics (0, 3, 6, 9, 12, 15, 18, 21)

plot for [i=1:n] sprintf('file_%i.dat', i) using ($1-o2+i*o1):2 with points

(これでうまくいくと思いますが、今はテストできません。)

于 2013-02-08T19:15:52.510 に答える