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 回答