【问题标题】:Create groups of dots histogram with gnuplot使用 gnuplot 创建点组直方图
【发布时间】:2013-02-08 17:07:54
【问题描述】:

我想用 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 做到这一点?

【问题讨论】:

    标签: gnuplot


    【解决方案1】:

    您可能必须手动为每组点设置偏移量,如下所示:

    #!/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
    

    (我认为这应该可以,但我现在无法测试。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-29
      • 2011-02-04
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 2017-08-25
      相关资源
      最近更新 更多