Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gnuplot 设置splot输出的定义区域_Gnuplot - Fatal编程技术网

Gnuplot 设置splot输出的定义区域

Gnuplot 设置splot输出的定义区域,gnuplot,Gnuplot,我想在gnuplot中创建一个效率图。因此,我在名为efficiency\u cloud.dat的数据文件中使用z作为效率的值(x y z) 我用splot绘制了一些数据。我想用一个二维的图表,用三维的轮廓来表示。这是可行的,但gnuplot推断。我不想显示外推的部分,因为在我的数据文件中没有值,而且它在物理上没有意义。 以下是我目前的代码: view map unset surface set dgrid3d 25,25,2.5 set contours set cntrparam leve

我想在gnuplot中创建一个效率图。因此,我在名为
efficiency\u cloud.dat
的数据文件中使用z作为效率的值(x y z)

我用
splot
绘制了一些数据。我想用一个二维的图表,用三维的轮廓来表示。这是可行的,但gnuplot推断。我不想显示外推的部分,因为在我的数据文件中没有值,而且它在物理上没有意义。 以下是我目前的代码:

view map
unset surface
set dgrid3d 25,25,2.5

set contours
set cntrparam levels incr 16,1,35

splot "efficiency_cloud.dat" using 1:2:3 with lines, "efficiency_cloud.dat" using 1:2:3 with labels
这就产生了一个如下的图片,我在后面手动添加了粉红色的线条。这只是一个例子
y=-1.5*x+250

手动添加图形作为边框示例的结果:

是否有一个选项仅显示图形下的部分

编辑: 正如作者在评论中所建议的,您需要将轮廓存储到文件中,然后过滤不需要的点

reset
set view map
unset key
unset surface
set dgrid3d 25,25,2.5
set contour
set cntrparam levels incr 16,1,35

set table "contours.dat"
splot "efficieny_cloud.txt" u 1:2:3 with lines
unset table
unset dgrid
unset contour
set surface

f(x)=-1.5*x+250

splot 'contours.dat' u 1:2:(f($1)<$2?0/0:0) w l

显然,您失去了添加标签的可能性,因为这意味着要混合等高线/非等高线、dgrid/非dgrid和曲面/非曲面


在表格中保存只有标签的绘图,不仅仅是保存标签点(你可以要求gnuplot开发人员实现这样的事情,这应该不会那么困难)

几个小时后,我找到了一个解决方案:我们首先需要使用
设置表格
splot
等高线。为了确保它们只在特定区域可见,我们创建了两个函数(上限和下限),使用
fit
并结合许多参数,因此我们的函数非常适合

现在我们用前面说过的条件进行绘图。因此,我们使用小参数
every
解决标签问题

这就是:

unset key
unset xtics

unset ytics

set view map
unset surface
set dgrid3d 15,15,2.5

# create contours
set contours
set cntrparam cubicspline
set cntrparam levels discrete 20, 24, 26, 28, 29, 30, 32, 33, 34, 35

# create file
set table 'contours_eta'
splot [0:100] "data_efficiency.dat" using 1:2:3 with lines
unset table

unset dgrid3d

# define styles
set style line 1 lt 1 lc rgb 'black'
set style textbox opaque margins  0.5,  0.5 noborder 
set style line 2  lt 0 lc rgb '#0025ad' dt 11 lw 1    

# upper limit
f0(x) = at0 + bt0*x + ct0*x**2 + dt0*x**3 + et0*x**5 + ft0*x**6 + gt0*x**7
fit [0:100] f0(x) "file_with_points_for_upper_limit.dat" using 1:2 \
via at0,bt0,ct0,dt0,et0,ft0,gt0

# lower limit
g0(x) = ab0 + bb0*x + cb0*x**2 + db0*x**3 + eb0*x**5 + fb0*x**6 + gb0*x**7
fit [0:100] g0(x) "file_with_points_for_lower_limit.dat" using 1:2 \
via ab0,bb0,cb0,db0,eb0,fb0,gb0

# variable for the density of the labels
incr = 40

plot [0:80] [0:250] "file_with_points_for_upper_limit.dat" w l ls 1,\
  "file_with_points_for_lower_limit.dat" w l ls 1,\
  for [n=0:20] 'contours_eta' index (n) u 1:((f0($1) > $2) && (g0($1) < $2)) ? $2 : 0/0 ls 2 w l,\
  'contours_eta' index 0:20 every incr u 1:(((f0($1) > $2) && (g0($1) < $2)) ? $2 : 0/0):(((f0($1) > $2) && (g0($1) < $2)) ? $3 : 0/0) w labels center boxed
unset键
未设置xtics
取消加密
设置视图地图
未定型表面
设置dgrid3d 15,15,2.5
#创建轮廓
设定轮廓
设置cntrparam cubicspline
设置cntrparam水平离散20、24、26、28、29、30、32、33、34、35
#创建文件
设置表格“等高线”
splot[0:100]“data\u efficiency.dat”使用1:2:3和行
未设置的表
取消设置dgrid3d
#定义样式
设置样式行1 lt 1 lc rgb“黑色”
将样式文本框不透明边距设置为0.5,0.5
设置样式行2 lt 0 lc rgb'#0025ad'dt 11 lw 1
#上限
f0(x)=at0+bt0*x+ct0*x**2+dt0*x**3+et0*x**5+ft0*x**6+gt0*x**7
使用1:2拟合[0:100]f0(x)“文件\u和\u上限.dat的\u点”\
通过at0、bt0、ct0、dt0、et0、ft0、gt0
#下限
g0(x)=ab0+bb0*x+cb0*x**2+db0*x**3+eb0*x**5+fb0*x**6+gb0*x**7
使用1:2拟合[0:100]g0(x)“带\u点的文件\u,用于\u下限.dat”\
通过ab0、bb0、cb0、db0、eb0、fb0、gb0
#标签密度的变量
增量=40
plot[0:80][0:250]“带上限点的文件.dat”w l ls 1\
“文件中包含下限.dat的点”w l ls 1\
[n=0:20]“等高线”指数(n)u1:((f0($1)>2)和(&&(g0($1)<2))$2:0/0升2瓦升\
“等高线”指数0:20每增加1:((f0($1)>2美元)和&(g0($1)<$2))?$2:0/0:((f0($1)>2美元)和&(g0($1)<$2))?$3:0/0)带中间盒装标签

谢谢你的帮助

当然,gnuplot会进行外推,因为使用
set dgrid3d
可以明确地告诉您这样做。是的,这是真的,但是如果能说出不应该在哪里显示外推,那就太好了。在这种情况下,不可能到达特定区域上方的区域。这就是为什么我不想在那里策划一些事情@bibi的方法应该可行,但要使其正常工作,必须首先将插值数据保存到一个中间文件,然后使用条件:
set dgrid3d 25,25;设置表格“效率\云\平滑.dat”;splot'efficiency_cloud.dat'u 1:2:3;未设置表;取消设置dgrid3d;splot'efficiency\u cloud\u平滑。dat'u…
。是的,这也是我现在的想法。然后它就成功了!但我对标签有问题。如何添加它们?尤其是在正确的位置(而不是在图表上方)添加它们?不幸的是,您的第一个备选方案不起作用。第二种方法不适合我,因为函数将是高维函数,而生成多边形将是。。。很难。你能把数据贴到什么地方吗,这样我就能知道为什么第一个解决方案不起作用了?是的,我可以这样做。有一个共同的地方/主人吗?不,一点也不:(难怪我会看起来不一样,我操纵了som参数…)非常感谢。我还找到了一个打印标签的解决方案:我用一个程序创建了一个文件,其中的点位于正确的位置,z值正确。然后我使用
set table'labels'
,然后使用1:2:3和标签来回复'labels'。太好了,谢谢。但是:不幸的是,我意识到我的图形将是原始数据,没有像使用的
f(x)=-1.5*x+250
中那样的函数
fit
找不到合适的函数,所以我想现在不可能实现它了。。。?
stats'efficieny_cloud.txt'
g(x)=STATS_max_y
plot "contours.dat" u 1:2 w l, "+" u 1:(f(x)):(g(x)) w filledcur 
unset key
unset xtics

unset ytics

set view map
unset surface
set dgrid3d 15,15,2.5

# create contours
set contours
set cntrparam cubicspline
set cntrparam levels discrete 20, 24, 26, 28, 29, 30, 32, 33, 34, 35

# create file
set table 'contours_eta'
splot [0:100] "data_efficiency.dat" using 1:2:3 with lines
unset table

unset dgrid3d

# define styles
set style line 1 lt 1 lc rgb 'black'
set style textbox opaque margins  0.5,  0.5 noborder 
set style line 2  lt 0 lc rgb '#0025ad' dt 11 lw 1    

# upper limit
f0(x) = at0 + bt0*x + ct0*x**2 + dt0*x**3 + et0*x**5 + ft0*x**6 + gt0*x**7
fit [0:100] f0(x) "file_with_points_for_upper_limit.dat" using 1:2 \
via at0,bt0,ct0,dt0,et0,ft0,gt0

# lower limit
g0(x) = ab0 + bb0*x + cb0*x**2 + db0*x**3 + eb0*x**5 + fb0*x**6 + gb0*x**7
fit [0:100] g0(x) "file_with_points_for_lower_limit.dat" using 1:2 \
via ab0,bb0,cb0,db0,eb0,fb0,gb0

# variable for the density of the labels
incr = 40

plot [0:80] [0:250] "file_with_points_for_upper_limit.dat" w l ls 1,\
  "file_with_points_for_lower_limit.dat" w l ls 1,\
  for [n=0:20] 'contours_eta' index (n) u 1:((f0($1) > $2) && (g0($1) < $2)) ? $2 : 0/0 ls 2 w l,\
  'contours_eta' index 0:20 every incr u 1:(((f0($1) > $2) && (g0($1) < $2)) ? $2 : 0/0):(((f0($1) > $2) && (g0($1) < $2)) ? $3 : 0/0) w labels center boxed