gnuplot 中的抖动点。数据输入文件格式
Jitter points in gnuplot. Data input file format
我能够从这里成功重现抖动示例:http://gnuplot.sourceforge.net/demo/violinplot.html
但是,当我尝试使用自己的数据时,点数不是"jittered"。
这是数据文件(data.dat):
10 1 1 3 8 8 8
20 2 2 3 8 8 8
30 3 3 3 8 8 8
这是一个最小的 gnuplot 输入文件:
set jitter
plot 'data.dat' using 1:2 with points, '' u 1:3 with points, '' u 1:4 with points, '' u 1:5 with points, '' u 1:6 with points, '' u 1:7 with points
这些点彼此重叠,而我希望位于同一位置的点稍微偏移(x 轴)。
我已经安装了最新版本的 gnuplot:
$ gnuplot --version
gnuplot 5.2 补丁级别 6
用解决方案编辑:
@Ethan 的评论让我明白了。我可以通过重新组织我的输入数据文件来消除抖动,使其成为一个包含内部 "collisions" 的数据集,而不是读取大量单独的数据集。例如:
10 1
10 1
10 3
10 3
20 2
20 2
30 8
30 8
我的 gnuplot 文件现在只是:
set jitter
plot 'data.dat' using 1:2 with points
如评论中所述,"set jitter" 将不适用于多个数据集。您可以通过在 'using' 说明符中添加随机位移来做类似的事情。
plot for [col=2:7] 'data.dat' using 1:(column(col) + (rand(0)-0.5)/2.) with points
这与 "set jitter" 不同,因为 所有 点将随机移动,而抖动仅重叠点移动且移动不是随机的。
或者,因为在您的情况下,列是不同的,也许您想根据列号系统地移动:
plot for [col=2:7] 'data.dat' using (column(1)+col/4.) : (column(col))
我能够从这里成功重现抖动示例:http://gnuplot.sourceforge.net/demo/violinplot.html
但是,当我尝试使用自己的数据时,点数不是"jittered"。
这是数据文件(data.dat):
10 1 1 3 8 8 8
20 2 2 3 8 8 8
30 3 3 3 8 8 8
这是一个最小的 gnuplot 输入文件:
set jitter
plot 'data.dat' using 1:2 with points, '' u 1:3 with points, '' u 1:4 with points, '' u 1:5 with points, '' u 1:6 with points, '' u 1:7 with points
这些点彼此重叠,而我希望位于同一位置的点稍微偏移(x 轴)。
我已经安装了最新版本的 gnuplot: $ gnuplot --version gnuplot 5.2 补丁级别 6
用解决方案编辑: @Ethan 的评论让我明白了。我可以通过重新组织我的输入数据文件来消除抖动,使其成为一个包含内部 "collisions" 的数据集,而不是读取大量单独的数据集。例如:
10 1
10 1
10 3
10 3
20 2
20 2
30 8
30 8
我的 gnuplot 文件现在只是:
set jitter
plot 'data.dat' using 1:2 with points
"set jitter" 将不适用于多个数据集。您可以通过在 'using' 说明符中添加随机位移来做类似的事情。
plot for [col=2:7] 'data.dat' using 1:(column(col) + (rand(0)-0.5)/2.) with points
这与 "set jitter" 不同,因为 所有 点将随机移动,而抖动仅重叠点移动且移动不是随机的。
或者,因为在您的情况下,列是不同的,也许您想根据列号系统地移动:
plot for [col=2:7] 'data.dat' using (column(1)+col/4.) : (column(col))