Splitting a line in gnuplot based on a column

ぃ、小莉子 提交于 2020-01-06 02:41:09

问题


I have a bunch of data like this:

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

I want to plot something like this on gnuplot:

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

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?


回答1:


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)

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



来源:https://stackoverflow.com/questions/27630046/splitting-a-line-in-gnuplot-based-on-a-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!