混合数据和参数的splot

混合数据和参数的splot,plot,gnuplot,Plot,Gnuplot,我有两条曲线作为数据点(即两组两元组)。我想展示它们加权和的表面,权重是第三个轴(就像从一条曲线到另一条曲线的平滑过渡) 示例:如果我有函数sin(x)和x**2/100,我可以这样实现它: set isosamples 100 splot [-10:10] [0:1] y * sin(x) + (1-y) * (x**2 / 100) 然而,在我的例子中,我没有函数,只有数据文件中的值,我不知道如何将其与自动运行值(如上面示例中的权重y)相结合。我试过,例如,这个,但不起作用: splot

我有两条曲线作为数据点(即两组两元组)。我想展示它们加权和的表面,权重是第三个轴(就像从一条曲线到另一条曲线的平滑过渡)

示例:如果我有函数
sin(x)
x**2/100
,我可以这样实现它:

set isosamples 100
splot [-10:10] [0:1] y * sin(x) + (1-y) * (x**2 / 100)
然而,在我的例子中,我没有函数,只有数据文件中的值,我不知道如何将其与自动运行值(如上面示例中的权重
y
)相结合。我试过,例如,这个,但不起作用:

splot [] [0:1] 'datafile' using 1:(y):(y * $2 + (1-y) * $3)

我得到的错误是
未定义变量:y
(这很清楚)。我只是不知道如何将数据文件中的数据与运行参数结合起来。

我想到的第一个想法是将“混合”数据绘制到一个表中。我希望有更好的办法

代码:

### mixing of parameter and data
reset session

# create some test data
set table $Data
    plot '+' u 1:(sin($1)):($1**2/100.) w table
unset table

N = 20.0    # float number to avoid integer division
set table $Mix
    do for [i=0:N] {
        plot $Data u 1:(i/N):(i/N*$2 + (1-i/N)*$3) w table
        plot '+' u ("") every ::0::0 w table   # plot "empty line" to disconnect lines
    }
unset table

set view 48,9
set ztics 0.5
splot $Mix u 1:2:3 w l
### end of code
结果:

### mixing of parameter and data
reset session

# create some test data
set table $Data
    plot '+' u 1:(sin($1)):($1**2/100.) w table
unset table

N = 20.0    # float number to avoid integer division
set table $Mix
    do for [i=0:N] {
        plot $Data u 1:(i/N):(i/N*$2 + (1-i/N)*$3) w table
        plot '+' u ("") every ::0::0 w table   # plot "empty line" to disconnect lines
    }
unset table

set view 48,9
set ztics 0.5
splot $Mix u 1:2:3 w l
### end of code

如果只需要平滑过渡,可以使用
dgrid3d

set table $Data
   plot '+' u 1:($1**2/100.) w table
   plot '+' u ("") every ::0::0 w table   # plot "empty line" to disconnect lines
   plot '+' u 1:(sin($1)) w table
unset table

set view 48,9
set ticslev 0

set dgrid3d 20,100 splines
splot $Data us 1:-1:2 w l 
-1
索引数据集。

如果您的x数据是均匀采样的,您可以将其简化为

set table $Data
   plot '+' u ($1**2/100.):(sin($1)) w table
unset table

set dgrid3d 20,100 splines
splot $Data matrix us ($2/10-5):1:3 w l

您的数据文件的结构是什么?2个文件,每个文件有2列(x,z),或者1个文件有3列(x,z1,z2),或者1个文件有4列(x1,z1,x2,z2)?我假设您有公共x?我的数据文件(只有一个)有三列。x、 y1和y2。(x | y1)和(x | y2)是两条曲线的坐标。是的,我有一个普通的x。你可以把y也叫做z,以避免在我的问题中与y混淆,对吗。(实际上,这个文件中有更多的列,我的曲线类似于
($2/($3+$4))
,但我希望这不会成为问题。)