2012-03-12 676 views
0

之间filledcurve我有两个点集:“test1.dat”和“test2.dat”,它们不共享相同的X值。gnuplot的:平滑曲线

由于数据很嘈杂,我想首先绘制两条平滑线,然后在平滑线之间绘制一条填充曲线。

我已经阅读教程,并不能找到答案。

回答

1

拉斐尔罗斯的回答捎带回来,看着gnuplot文档,你可能也可以实现这一点与数据集的小壳魔法不共享X值以及。我测试了这一点,当发现

plot '< tail -r test2.dat | cat test1.dat -' using 1:2 with filledcurves closed 

的一件事是,你应该确保你有test2.dat结束换行符,否则tail -r将无法​​正常工作(tac可能会工作过,但它没有安装在我的苹果机上,它的作用是取第一个数据文件并将第二个数据文件附加到第一个数据文件(我假定第一个和第二个数据文件已经按升序X值排序)换句话说,据gnuplot的而言,数据是上升的X,则在X下降。因为我们使用的with filledcurves closed的gnuplot把所有点作为一个多边形,然后连接它们。至于平滑的数据,那是另一个问题完全。只是看看在文档中,gnuplo t提供了一些平滑算法,但它们需要提前用于数据。以下是经过充分测试,但希望将类似的东西你想要什么(它也可能只在UNIX类型的环境工作)...

set table 'smoothed1' 
plot 'test1.dat' using 1:2 smooth beizer #beizer is just an example see "help plot datafile smooth" for more options 
unset table 

set table 'smoothed2' 
plot 'test2.dat' using 1:2 smooth beizer 
unset table 

plot '< tail -r smoothed2 | cat smoothed1 -' using 1:2 with filledcurves closed 

如果它不工作,看看gnuplot生成的文件“平滑1”和“平滑2”,看看是否给你任何提示(例如是否有额外的换行符应该删除?)

+0

我得到一个“无法识别的‘平滑’选项” – 2015-11-24 11:49:07

+0

好像是因为“beizer”必须orthographed“贝塞尔” – 2015-11-24 12:06:29

1

是据我所知,在2个不同的文件中使用的数据的Gnuplot不能使地块。在这种情况下,我调用一个BASH程序,比如“粘贴”来合并这两个文件。我认为这两个文件中包含的格式为“XY”的数据,他们都有一个共同的X-格(数据点的数量也必须等于)

plot '<paste test1.dat test2.dat' u 1:2:4 w filledcurve 

PS:如果你不使用Linux的我不知道knwo如何做到这一点......

+1

数据作图fropm两个不同的文件是可能的:'情节 “test1.dat” 使用1 “test2.dat” 使用2'产生反映每个文件中的数据点的图形。 – vaettchen 2012-03-12 18:25:20

+1

另一个问题是,我想先拿到两个流畅的线条,使数据是嘈杂。然后在平滑线之间填充曲线。 – toby 2012-03-13 00:45:44

+0

我更喜欢使用外部程序进行数据处理(例如平滑)。这可以是小的shell/python /脚本,可以使用类似于上面的例子..但它不是一个很好的解决方案。为此,最好使用Python中嵌入的Gnuplot(Gnuplot.py),您可以在1个脚本中使用Numpy/Scipy进行数据处理...... – 2012-03-13 10:08:13

0

这适用于我。第一与上平滑线和x轴之间的一些颜色填充,第二填充下线和x轴之间的白色,最后绘制两个平滑线。

光滑CSPLINE必须filledcurve是前

plot "test1.dat" using ($1):($2) notitle smooth cspline with filledcurve x1 lt rgb "#FFAAAA",\ "test2.dat" using ($1):($2) notitle smooth cspline with filledcurve x1 lt rgb "#FFFFFF",\ "test1.dat" using ($1):($2) notitle w l lw 2 lt 1 lc 0 smooth cspline,\ "test2.dat" using ($1):($2) notitle w l lw 2 lt 1 lc 1 smooth cspline