gnuplot - 如何使用 gnuplot 将非矩形和未网格化的数据显示为 map ?

标签 gnuplot triangulation delaunay

让我们假设以下 100 个具有 x、y、z 值的点。

数据:(tbTriangulationTest.dat)

-7.6392 -11.107 84.8488
0.903339 9.3734 8.46736
-14.1859 20.7705 -294.647
1.70653 0.400903 0.684154
-7.15958 4.18987 -29.9977
-7.4528 4.57573 -34.102
-6.92655 12.5265 -86.7655
7.19843 12.2755 88.364
7.6977 4.97676 38.3096
7.7979 -12.6609 -98.7287
-7.05982 7.2656 -51.2938
-6.24214 -5.79787 36.1911
5.07354 -5.66814 -28.7575
2.14596 -24.9946 -53.6374
14.466 4.81118 69.5987
15.4306 -2.16115 -33.3478
11.1028 -1.0111 -11.2261
-11.4716 2.55607 -29.3223
-0.256364 14.5526 -3.73077
-6.83535 2.39029 -16.3385
3.19476 6.24488 19.9509
-7.72445 0.172802 -1.3348
-4.39985 7.86195 -34.5914
2.31929 13.8717 32.1724
2.4772 10.766 26.6694
-3.84819 0.687076 -2.644
-3.38394 2.43134 -8.22753
-14.4258 -0.320421 4.62232
0.359401 16.5257 5.93933
-0.11949 -6.9755 0.833503
0.0203191 14.5566 0.295777
5.26722 -10.3545 -54.5394
1.76742 3.98467 7.04257
-1.86885 13.3988 -25.0403
-1.07509 -7.08523 7.61723
7.47418 -7.07921 -52.9113
-0.109939 5.9067 -0.649376
-6.54697 2.69141 -17.6206
1.93999 6.87386 13.3352
9.99989 -5.95029 -59.5023
-8.83706 6.71112 -59.3066
6.74163 -1.71645 -11.5717
-4.12996 2.70168 -11.1578
6.29323 4.01845 25.289
18.2854 1.91548 35.0253
9.09857 12.9239 117.589
-9.01182 -11.5522 104.106
11.3029 -10.4565 -118.19
-24.4571 1.79031 -43.7857
19.34 -12.7014 -245.644
-10.2519 4.79582 -49.1662
6.24068 1.32636 8.27735
-15.0611 21.314 -321.012
12.2994 -22.9166 -281.861
4.53579 -3.02911 -13.7394
-2.30123 10.4506 -24.0492
-3.25415 -1.33511 4.34464
-0.235662 -7.96686 1.87749
21.0184 6.90852 145.206
0.643772 4.77797 3.07592
-13.3988 -7.69317 103.08
-2.49046 2.3838 -5.93674
-4.37109 -13.7552 60.1251
-3.29135 -4.70658 15.491
-5.11691 -18.2533 93.4004
12.3443 -11.7966 -145.621
13.0676 15.3554 200.659
17.5267 -15.0171 -263.202
2.71931 -3.37602 -9.18042
0.998506 -4.7515 -4.74441
-5.89248 3.18231 -18.7517
0.137122 -0.471599 -0.0646664
7.8984 20.8154 164.409
7.78891 -15.5838 -121.381
-9.83 -1.36857 13.453
9.36609 0.0750601 0.70302
-13.0303 -0.141129 1.83895
16.3977 -5.6081 -91.9598
2.33021 1.19008 2.77313
11.5595 -5.43006 -62.7686
-0.801337 14.7878 -11.85
5.32441 -5.41455 -28.8293
23.4373 14.0071 328.288
-17.7308 1.2621 -22.378
-0.820822 -7.65832 6.28611
-2.78152 15.6323 -43.4815
-0.294363 -2.24102 0.659673
20.2027 -4.30447 -86.962
-3.97186 9.53271 -37.8626
14.0495 -5.68544 -79.8777
1.8913 11.6477 22.0292
6.6496 0.813952 5.41246
8.37437 -6.54425 -54.804
4.78983 -9.09723 -43.5742
14.9403 -3.81761 -57.0361
-1.81065 -8.15522 14.7663
-11.7699 5.49208 -64.641
-8.61747 10.5284 -90.728
0.0274375 -7.02236 -0.192676
0.125369 5.45746 0.684198

现在,我想绘制此数据的高度图。 使用以下代码,我得到以下结果。

代码:

reset session

set term wxt size 630,630
FILE = "tbTriangulationTest.dat"

set view map
set palette rgb 33,13,10
set xrange [-30:25]
set yrange [-30:25]
set xtic 5
set ytic 5

set dgrid3d 100,100 gauss 5

splot FILE w pm3d

结果:

enter image description here

这张图看起来不错,但是,在我看来,它不一定能给人以真实的数据印象,因为实际上根本没有数据的外部区域将被着色。嗯,这是矩形网格化的结果。此外,根据插值方法,可能会出现伪影。

那么,我的问题是:

在 gnuplot 中是否有更好的方法将非矩形和未网格化的数据显示为 map ?

最佳答案

四个月后,gnuplot 的开发版本现在提供了基于我最初建议的凸包 + 掩蔽曲面方法的解决方案。凸包部分本来可以在脚本中完成,但它似乎是一个通常有用的东西来构建。使用多边形作为掩码是新的。这是用户手册中的相关部分。

掩蔽

The plotting style with mask is used to define a masking region that can be applied to pm3d surfaces or to images specified later in the same plot or splot command. Input data is interpreted as a stream of [x,y] or [x,y,z] coordinates defining the vertices of one or more polygons. As in plotting style with polygons, polygons are separated by a blank line. If the mask is part of a 3D (splot) command then a column of z values is required on input but is currently not used for anything. If a mask definition is present in the plot command, then any subsequent image or pm3d surface in the same command can be masked by adding the keyword mask. If no mask has been defined, this keyword is ignored.

set table $HULL
plot $POINTS using 1:2 convexhull
unset table

set dgrid3d 100,100 gauss 5
set multiplot layout 1,2
splot $POINTS using 1:2:3 with pm3d, \
      $POINTS using 1:2:(0) nogrid with points
splot $HULL using 1:2:(0) with mask, \
      $POINTS using 1:2:3 mask with pm3d
unset multiplot

enter image description here

This example illustrates using the convex hull circumscribing a set of points to mask the corresponding region of a pm3d surface. The splot command for the first panel renders the unmasked surface and the set of points, plotted in that order. The splot command for the second panel renders the masked surface. Note that definition of the mask must come first (plot style with mask), followed by the pm3d surface it applies to (plot style with pm3d modified by the mask keyword). A more complete version of this example is in the online demo collection mask_pm3d.dem

The masking commands are EXPERIMENTAL. Details may change before inclusion in a stable release version.

关于gnuplot - 如何使用 gnuplot 将非矩形和未网格化的数据显示为 map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68507660/

相关文章:

gnuplot - Gnuplot 中非数值数据的 x 范围

c# - 有什么办法可以将gnuplot的图表合并到winform中

shell - 在术语哑绘图模式下在 gnuplot 生成的图形中注入(inject)颜色

c++ - 获取顶点索引以保存三角剖分

c++ - poly2tri getTriangles() 和 getMap() 有什么区别?

opencv - OpenCV中Delaunay三角剖分的匹配结果

Gnuplot 根据值在框上垂直渐变?

opencv - C++-ObjC OpenCV 约束 Delaunay

java - 将C代码转换为Java(分而治之的delaunay三角剖分算法)