问题描述
我正在从数据文件中绘制表面。我想删除与x轴平行的网格线。
I am plotting a surface from a data file. I want to remove the mesh line parallel to x axis.
这是我的代码:
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
这将产生:
我需要的是:
第二个数字是通过添加虚拟数据行生成的:
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?
推荐答案
最简单的方法是将每个空行替换为两个空行。然后,每个x值都有一个数据块。并且不同块中的点彼此不连接:
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:
文件 data.txt
包含:
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
现在用
splot '< sed "s/^$/\n/g" data.txt' w l
得到
如果不能使用 sed
,则必须使用与:
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
这篇关于Gnuplot:如何在曲面图中删除与x轴平行的网格线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!