根据列在gnuplot中分割一行 [英] Splitting a line in gnuplot based on a column

查看:76
本文介绍了根据列在gnuplot中分割一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆这样的数据:

0 0 50.5 -3.39358e-05
0 0 150.5 5.11472e-06
0 0 250.5 -3.87604e-06
0 0 350.5 -2.54219e-05
0 0 450.5 3.92257e-06
0 0 550.5 0.00198317
0 0 650.5 -4.96953e-05
0 0 750.5 -3.60458e-05
0 0 850.5 -2.30878e-05
0 0 950.5 1.67545e-07
1 0 126.5 4.17028e-05
1 0 226.5 -1.43637e-05
1 0 326.5 1.42918e-06
1 0 426.5 1.18147e-05
1 0 526.5 0.0020478
1 0 626.5 1.58651e-06
1 0 726.5 3.18537e-05
1 0 826.5 2.47536e-05
1 0 926.5 -4.20655e-05

我想在gnuplot上绘制这样的内容:

I want to plot something like this on gnuplot:

plot file using 3:($4+$1*factor) with lines

但是,这给了我所有数据连续的一行.我要为$1的每个唯一值使用一行.即,对于$1=0的所有数据,连续的一行,对于$1=1的另一行,依此类推.如何在行中添加这样的不连续性?

But this gives me one continuous line for all the data. I want one line for each unique value of $1. ie., one continuous line for all data where $1=0, then another line for $1=1 and so on. How can I add such a discontinuity in the line?

推荐答案

每当第一列中的值发生更改时,您就可以使用外部工具对数据进行预处理以添加空行(不适用于Windows):

You can use an external tool to preprocess your data to add an empty line whenever the value in the first column changes (doesn't work on Windows):

plot '< awk ''{if(x!=$1) {print ""}; x=$1;print}'' test.dat' using 3:($4 + $1*factor)

数据文件中的空行阻止gnuplot连接分离的数据点.

The empty line in the data file prevents gnuplot from connecting the separated data points.

这篇关于根据列在gnuplot中分割一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆