Gnuplot: How to remove mesh line parallel to x axis in surface plot

人走茶凉 提交于 2019-12-11 04:16:35

问题


I am plotting a surface from a data file. I want to remove the mesh line parallel to x axis.

Here is my code:

set xlabel 'x';
set ylabel 'y';
splot "-" using 1:2:3 notitle w l;
1 1.0 0.998
1 2.0 0.998
1 3.0 0.998
1 4.0 0.998
1 5.0 0.997
1 6.0 0.997
1 7.0 0.997
1 8.0 0.997
1 9.0 0.997
1 10.0 0.997

2 1.0 0.998
2 2.0 0.997
2 3.0 0.996
2 4.0 0.995
2 5.0 0.995
2 6.0 0.995
2 7.0 0.995
2 8.0 0.994
2 9.0 0.989
2 10.0 0.987

3 1.0 0.997
3 2.0 0.997
3 3.0 0.997
3 4.0 0.997
3 5.0 0.997
3 6.0 0.997
3 7.0 0.996
3 8.0 0.996
3 9.0 0.995
3 10.0 0.994

4 1.0 0.997
4 2.0 0.996
4 3.0 0.993
4 4.0 0.99
4 5.0 0.986
4 6.0 0.982
4 7.0 0.977
4 8.0 0.974
4 9.0 0.966
4 10.0 0.959
e

This will produce:

What I need is:

The second figure is produced by adding a dummy data line:

2 11.0 0.987

However, I am plotting from load of data files. I can not modify each data file to add a dummy data line. Is it possible by not adding dummy data line to produce the second figure?


回答1:


The easiest way is to replace every empty line with two empty lines. Then you have one data block for every x-value. And points in different blocks aren't connected with each other:

The file data.txt contains:

1 1.0 0.998
1 2.0 0.998
1 3.0 0.998
1 4.0 0.998
1 5.0 0.997
1 6.0 0.997
1 7.0 0.997
1 8.0 0.997
1 9.0 0.997
1 10.0 0.997

2 1.0 0.998
2 2.0 0.997
2 3.0 0.996
2 4.0 0.995
2 5.0 0.995
2 6.0 0.995
2 7.0 0.995
2 8.0 0.994
2 9.0 0.989
2 10.0 0.987

3 1.0 0.997
3 2.0 0.997
3 3.0 0.997
3 4.0 0.997
3 5.0 0.997
3 6.0 0.997
3 7.0 0.996
3 8.0 0.996
3 9.0 0.995
3 10.0 0.994

4 1.0 0.997
4 2.0 0.996
4 3.0 0.993
4 4.0 0.99
4 5.0 0.986
4 6.0 0.982
4 7.0 0.977
4 8.0 0.974
4 9.0 0.966
4 10.0 0.959

Now plot this with

splot '< sed "s/^$/\n/g" data.txt' w l

to get

If you cannot use sed, you must use an approach similar to the one shown in plot matrix with lines gnuplot:

stats 'data.txt' nooutput
splot for [i=0:STATS_blank] 'data.txt' every :::i::i lt 1 w l


来源:https://stackoverflow.com/questions/23785197/gnuplot-how-to-remove-mesh-line-parallel-to-x-axis-in-surface-plot

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