Back to demo index

gnuplot demo script: mask_pm3d.dem

autogenerated by webify.pl on Sun Sep 17 20:23:18 2023
gnuplot version gnuplot 6.0 patchlevel rc2
#
# Demonstrate construction of a convex hull used to mask
# out regions of a surface that are outside a cluster of points.
# Inspired by a Stack Overflow query from @theozh
#    https://stackoverflow.com/questions/68507660/
#

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

set margins screen 0.2, screen 0.8, screen 0.1, screen 0.9
unset key
set tics scale 0

set title "Convex hull constructed around scattered points"
plot  'mask_pm3d.dat' using 1:2:3 with points lc palette pt 7 ps 2, \
      '' using 1:2 convexhull lc "black" lw 3

set table $HULL
plot 'mask_pm3d.dat' using 1:2 convexhull with lines title "Convex hull"
unset table
print $HULL


Click here for minimal script to generate this plot



#
# Show the convex hull polygon and the full (unmasked pm3d surface)
#
set pm3d explicit
set dgrid3d 100,100 gauss 5

set title "pm3d surface generated from points by dgrid3d"
splot  'mask_pm3d.dat' using 1:2:3 with pm3d, \
      $HULL using 1:2:(0) with lines lc "black" lw 3 nogrid


Click here for minimal script to generate this plot



#
# Now we use the convex hull polygon to mask the surface
#

set title "pm3d surface masked by convex hull"
set pm3d interp 3,3

splot  $HULL using 1:2:(0) with mask, \
       'mask_pm3d.dat' using 1:2:3 mask with pm3d


Click here for minimal script to generate this plot


reset