Search code examples
3dgnuplot

plotting points on 3d surface with pm3d in gnuplot


I'm trying to plot a point on 3d surface and also on the base of 3d surface using gnuplot. Below is the code that I'm using, the data "datx.dat" is in following location https://www.dropbox.com/s/8evj5da7yco1xmo/datx.dat?dl=0

set dgrid3d 100,100
set cntrparam levels disc -242.3,-242.5,-243,-244,-245,-246,-247,-248
set contour both                                                     
set hidden3d back offset 1 trianglepattern 3 undefined 1 altdiagonal bentover        
#set palette rgbformulae 12,12,12                                                     
set view 50,320                                                                      
set contour both
unset key 
unset colorbox

$data << EOD                     
1175.4,1.61,-242.01
EOD

splot 'datx.dat' using 1:2:3 with pm3d, \
      $data using 1:2:3 with labels point pt 7

Below is the output, I dont see the point at desired location. How do I achieve this in gnuplot?

enter image description here

Desired output:

enter image description here


Solution

  • The reason it doesn't work is that set contours ... splot $DATA with labels tells the program to contour $DATA and place labels along those contours. Obviously there can be no contours generated for a single-point data set so there is no place to position a label.

    The easiest way to place a single point at a known position on the surface is:

    set label 1 "" at 1175.4,1.61,-242.01 point pt 7     
    # make sure it is not obscured by the surface
    set label 1 front
    

    Placing a point on the base is also easy, so long as you specify exactly where the base is going to be drawn (rather than trying predict where the auto-placement will end up):

    Zbase = -500
    set xyplane at Zbase
    set label 2 "" at 1175.4, 1.61, Zbase point pt 7