【问题标题】:Set definition area for output of splot设置 splot 输出的定义区域
【发布时间】:2016-03-18 22:53:45
【问题描述】:

我想要创建的是 gnuplot 中的效率图。因此,我在名为efficiency_cloud.dat 的数据文件中将值 (x y z) 与 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

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

是否可以选择仅显示位于图表下方的部分?

【问题讨论】:

  • 当然是 gnuplot 推断,因为 set dgrid3d 你明确要求这样做。
  • 是的,这是真的,但最好说它不应该显示推断的位置。在这种情况下,不可能到达某个区域之上的区域。这就是为什么我不想在那里绘制一些东西的原因
  • 好的。 @bibi 的方法应该有效,但要使其正常工作,您必须首先将插值数据保存到中间文件,然后使用条件绘制该文件:set dgrid3d 25,25; set table 'efficiency_cloud_smoothed.dat'; splot 'efficiency_cloud.dat' u 1:2:3; unset table; unset dgrid3d; splot 'efficiency_cloud_smoothed.dat' u ...
  • 是的,这也是我现在的想法。然后它起作用了!但我对标签有疑问。我怎样才能添加它们?尤其是将它们添加到正确的位置(而不是在图表上)?

标签: gnuplot


【解决方案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/non-dgrid 和表面/非表面。

将只有标签的绘图保存在表格中,不仅仅是保存标签点(您可以请求 gnuplot-devs 来实现这样的事情,应该不难做到)

【讨论】:

  • 不幸的是,您的第一个替代方案不起作用。第二种方法不适合我,因为该函数将是一个更高维的函数,并且制作多边形会......很难。
  • 您能否在某处发布数据,以便我检查为什么第一个解决方案不起作用?
  • 是的,我可以这样做。有没有共同的地方/主持人?
  • 不,一点也不:pastebin.com/Ju6WhYgG(不要怀疑我会看起来不一样,我操纵了 som 参数......)
  • 非常感谢。我还找到了绘制标签的解决方案:我使用创建原始值的程序创建了一个文件,其中的点在正确的位置和正确的 z 值。然后我使用set table 'labels' 和后来的replot 'labels' using 1:2:3 with labels。太好了,谢谢。但是:不幸的是,我意识到我的图表将是原始数据,没有像使用过的f(x)=-1.5*x+250 那样的功能。 fit没有找到合适的功能,估计现在不可能实现了……?
【解决方案2】:

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

所以现在我们按照@bibi 已经说过的条件进行绘图。所以解决我们使用小参数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

感谢您的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-06
    • 2017-02-14
    • 1970-01-01
    • 2015-01-14
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多