gnuplotunstructured-data

Mismatch of pm3d (color) & line 3D surface


Trying to plot a non-grid 3D dataset, I've used dgrid3d 960,960 to capture the many fluctuations of the z-values. Then I've plotted them with pm3d. To overlap it with the same 3D plot but with lines, I must reduce the parameters of dgrid3d to, say, 120,120 so that they may be individually visible. In principle that's an easy endeavor,

set dgrid3d 960,960
splot "FILE" w pm3d notitle
set dgrid3d 120,120 qnorm 9
rep "FILE" w l

The result displays a moderate mismatch between both plots, colored & gridded 3D plots

I guess that's because set dgrid3d 120,120 renders different z-approximated values than set dgrid3d 960,960. If I keep 960,960 for the plot with lines, then you can imagine... it comes all full of lines, 960 in each direction. And set isosamples doesn't work with dgrid3d. I wish there was something like rep "FILE" w l [120,120] but there is no. Any solution ?


Solution

  • This is not a full solution to your problem since it remains true that if you change the dgrid3d settings then the generated surface will also change. I didn't really notice it strongly in the image you posted,but it is very clear in the figure below. It does show how you can achieve your wish to change the gridding mid-stream while plotting. I take it that what you really want, however, is to keep the gridding the same but only draw every 10th line or so. That seems like a reasonable thing to do but I don't think it is currently possible in gnuplot.

    Note: This technique requires gnuplot verion 6!

    Several things to note in this script.

    Script:

    set palette defined (0 "dark-blue", 1 "white")
    set xrange noextend
    set yrange noextend
    set zrange [-0.6 : 1.6]
    set xyplane 0
    unset key
    
    set pm3d noborder explicit
    set hidden3d front
    
    function $set_grid(N) << EOF
        set dgrid3d N,N qnorm 9
    EOF
    
    splot A=$set_grid(480) "DATA" with pm3d at bs nohidden, \
          A=$set_grid(120) "DATA" with lines lw 1.0 lc "black"
    

    Result: enter image description here

    That said, you may get an acceptable result by making the grid not quite so fine and the lines in the second component of the plot thinner. Here is the same plot drawn with

    splot A=$set_grid(480) "DATA" with pm3d at bs nohidden, \
          A=$set_grid(480) "DATA" with lines lw 0.2 lc "black"
    

    enter image description here