2016-10-22 90 views
0

我想在gnuplot的一个splot内绘制虚线下面的代码4.6 PATCHLEVEL 4:gnuplot的:在splot虚线的变化密度

set terminal "pdfcairo" enhanced dashed size 15,10 
set pm3d map 
set output "test.pdf" 
splot 'map.dat' using 1:($2/1000):3 notitle, \ 
    'line1.dat' using 1:($2/1000):1 notitle with lines ls 2, \ 
    'line2.dat' using 1:($2/1000):1 notitle with lines ls 2 
unset output 

热图的作品也是如此line1.dat 。但是,第二行看起来很稳固。不同之处在于line1.dat有70个条目,line2.dat有900个。第二行有两个点之间的跳转,并且在那里是虚线。

有人知道我如何改变网点密度,以便整条线点缀。更改原始数据文件不是一个选项。

感谢你的帮助,

不一

编辑:

一个解决办法,我发现是

splot 'line2.dat' every ... 

但可以在数据跳得到unconvenient。

回答

1

命令(s)plot 'line.dat' with lines第一重复数据点,然后连接使用与所述相应线型线数据点。如果数据点彼此太靠近,则在使用虚线样式时,没有空间可用于某些间隙。

要显示虚线/虚线,您可以尝试用函数替换点或减少点数。

  • 尝试用虚线代替虚线。 Linestyle和linecolor可以独立设置:splot 'line.dat' with lines ls 0 lc 2。这种方法900点可能太多了。

  • 拟合一个函数是可行的,但可能很难找到合适的函数。

  • every选项可减少点数。

  • 减少点数的另一种方法是使用smooth选项对点进行插值。这需要一个临时文件和工作原理如下:

    # [prepare plot] 
    set samples 100 
    set table "line2.dat.tmp" 
    plot 'line2.dat' using 1:($2/1000) smooth mcsplines with lines ls 2 
    unset table 
    
    set terminal "pdfcairo" enhanced dashed size 15,10 
    set pm3d map 
    set output "test.pdf" 
    
    # [plot] 
    splot 'map.dat' using 1:($2/1000):3 notitle, \ 
        'line1.dat' using 1:($2/1000):1 notitle with lines ls 2, \ 
        'line2.dat.tmp' using 1:2:1 notitle with lines ls 2 
    
    unset output 
    

在[准备剧情]部分创建“line2.dat.tmp”,其中包含的数据点插值line2.dat的临时文件。你必须玩set samples以获得合适的分数。在这个例子中,我们有100个等距点,而不是距离不同的900个点。 选项smooth mcsplines保留了原始数据点的单调性和凸性,请参见gnuplot shell中的help smooth mcsplines

在[plot]部分中,原始的“lines2.dat”被内插数据替代。

如果原始数据足够平滑,以便将900个点替换100个点不会跳过重要信息,则此方法有效。也许你想在一张图中同时绘制“lines2.dat”和“lines2.dat.tmp”来比较它们。

+0

谢谢你的帮助。对于数据跳转,我使用了三个“每个”(第一部分,第一部分正确跳转,第二部分跳转)。 – noes

0

用户的every键字,这样的:

'line2.dat' every 20 using 1:($2/1000):1 notitle with lines ls 2