使用表格和凸包进行条件绘图

问题描述 投票:0回答:1

提供这些数据(datos.txt)

0   23      -0.3    26/11/2023 14:45:00
0   23.1    -0.3    26/11/2023 13:45:00
0   23.2     0      11/02/2023 18:15:00
0   24      -0.6    26/11/2023 15:15:00
0   25      -0.2    26/11/2023 13:15:00
0   26       0      11/02/2023 11:15:00
0   27      -0.3    26/11/2023 16:15:00
0   28      -0.1    26/11/2023 12:45:00
0   29       0      11/02/2023 10:45:00
0   30      -0.2    30/10/2022 16:15:00
0   32       0      12/02/2023 18:15:00
0   32.1    -0.3    26/11/2023 11:45:00
0   33      -0.7    18/12/2023 13:15:00
0   34       0.1    12/06/2022 08:15:00
0   34.1     0.6    30/10/2022 16:45:00
0   34.2     0.3    12/05/2024 21:45:00
0   36      -0.3    26/11/2023 11:15:00
0   37      -0.5    28/01/2024 11:45:00
0   37.1    -0.4    22/01/2024 11:15:00
0   37.2    -0.2    31/10/2022 15:45:00
0   37.3    -0.3    12/01/2024 03:45:00
0   37.4    -0.5    18/12/2023 12:45:00
0   38      -0.7    29/10/2022 12:15:00
0   38.1    -0.2    22/03/2024 20:15:00
0   39      -1.4    19/12/2023 15:45:00
0   39.1     0.3    29/03/2023 09:45:00

还有这个脚本

reset session
set table $HULL                                                                                
plot "datos.txt" u (gprintf("%.1f",$1)):(($3)>0.2 && ($3)<0.7 ? (gprintf("%.f",$2)): NaN) w table convexhull                     
unset table                                                                                
print $HULL

我得到以下结果

0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0     34
0.0     34
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0      nan
0.0     39

有没有办法将only非nan行转储到$HULL文件中? 没有表格是可能的,但我不允许对 x 和 y 列使用显式格式。

gnuplot convex-hull
1个回答
0
投票

这种形式的

plot with table
命令将跳过任何与“if”条件不匹配的行

gnuplot> set table
gnuplot> plot "datos.txt" u (gprintf("%.1f",$1)) : (gprintf("%.f",$2)) \
      with table if (($3)>0.2 && ($3)<0.7)
0.0     34
0.0     34
0.0     39

但是

with table
对过滤或平滑操作一无所知,所以你不能在这里使用
convexhull

但是,您可以分两次完成此操作。 一次通过选择船体点,第二次通过以所需的格式打印它们:

set table $TEMP
plot "datos.txt" convexhull with points
unset table

set table $HULL
plot $TEMP u (gprintf("%.1f",$1)) : (gprintf("%.f",$2)) with table
unset table

我不确定过滤船体集中点的 y 值是否有意义,但如果您更详细地解释您想要做什么,也许会变得清楚。

© www.soinside.com 2019 - 2024. All rights reserved.