Here is one possibility:
- First draw the gridded data which you get with
set dgrid3d
to a temporary file usingset table
. - Use
stats
to get the maximum value (thesplot
inside theset table
doesn't set theGPVAL_DATA_Z_MAX
variable). - Plot the tabulated data
with image
to get your heatmap. Using this plotting style instead ofpm3d
makes sure, that the maximum value is located centered in a 'pixel'. - Plot a point only when the third column in the tabulated data corresponds to the maximum value.
The complete script:
set dgrid3d 20,200
set table 'd.table'
splot 'd.dat' u 1:2:3
unset table
stats 'd.table' u 3 nooutput
unset dgrid3d
set autoscale fix
unset key
plot 'd.table' with image,\
'' using 1:($3 == STATS_max ? $2 : NaN) with points pt 7
Using an example file
0 0 5
0 1 7
0 2 9
1 0 2
1 1 0
1 2 10
2 0 1
2 1 1
2 2 8
and set dgrid3d 4,4
gives you the following output (using 4.6.4):