设置splot

时间:2016-03-07 18:21:44

标签: gnuplot

我想要创建的是gnuplot中的效率图。因此,我将值(x y z)与z作为名为efficiency_cloud.dat的数据文件中的效率。

我使用splot绘制一些数据。我想在2D图形中显示第三维作为轮廓。这有效,但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

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

enter image description here

是否有选项只显示图表下方的部分?

2 个答案:

答案 0 :(得分:1)

编辑:

正如@Christoph的评论中所建议的那样,您需要将轮廓存储到文件中,然后过滤那些您不想要的点

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

plot "contours.dat" u 1:(f($1) > $2 ? $2: 0/0) with lines

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 

显然你没有添加标签的可能性,因为它意味着混合轮廓/非轮廓,dgrid /非dgrid和表面/非表面。

在表格中保存只有标签的情节,不只是保存了labal-points(你可以请求gnuplot-devs来实现这样的事情,它应该不那么难做)

答案 1 :(得分:0)

几个小时后我找到了一个解决方案:我们首先需要使用set tablesplot轮廓。为了确保它们仅在某个区域中可见,我们创建了两个函数(上限和下限),其中fit结合了许多参数,因此我们的函数非常适合。

所以现在我们用@bibi已经说过的条件进行绘图。因此,我们使用小参数every来解决标签问题。

Efficiency map with gnuplot

所以这是:

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

感谢您的帮助!