0

我正在尝试在 Gnuplot 4.6 patchlevel 4 中使用以下代码在 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 ...

但这可能会在数据跳跃时变得不方便。

4

2 回答 2

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
    

在 [prepare plot] 部分中,创建了一个临时文件“line2.dat.tmp”,其中包含插值 line2.dat 的数据点。你必须玩set samples才能获得正确的分数。在示例中,我们有 100 个等距点,而不是 900 个不同距离的点。该选项smooth mcsplines保留了原始数据点的单调性和凸性,请参见help smooth mcsplinesgnuplot shell。

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

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

于 2016-10-25T23:05:15.793 回答
0

使用每个关键字,如下所示:

'line2.dat' every 20 using 1:($2/1000):1 notitle with lines ls 2
于 2016-10-24T23:39:01.903 回答