Search code examples
gnuplot

Filled area in 3d in gnuplot


I am plotting a 3D heat map in gnuplot. I would like to plot a filled area on top of it. The datafile looks the following

118.01363   0.31794
139.62999   0.31216
173.51509   0.30177
210.90555   0.28675
244.79065   0.26942
268.15969   0.25209
293.86563   0.23764
318.40312   0.21974
341.77215   0.20414
303.21324   0.28270
292.69718   0.29194
279.25998   0.30350
254.13827   0.31794
234.27459   0.31967
173.51509   0.31563
153.65141   0.31274
139.62999   0.31216

I know how to get the result in 2d using plot 'data' w filledcurve, which gives the following result:

enter image description here

However, I cannot figure out how to plot it equivalently on a 3d map. I tried, e.g., splot 'data' u 1:2:(1) w filledcurve in order to obtain filledarea at constant value of z=1 but it does not do the job and it basically shows lines in z-axis direction:

enter image description here

Howe can I fill the area from the example at a constant value of z-axis on top of a pm3d map plot?


Solution

  • The plot style with polygons works in both 2D and 3D plots. You can provide a constant z value of zero or some other value to make sure the polygon sits in front of or behind whatever else is in the plot.

    $Data << EOD
    118.01363   0.31794
    139.62999   0.31216
    173.51509   0.30177
    210.90555   0.28675
    244.79065   0.26942
    268.15969   0.25209
    293.86563   0.23764
    318.40312   0.21974
    341.77215   0.20414
    303.21324   0.28270
    292.69718   0.29194
    279.25998   0.30350
    254.13827   0.31794
    234.27459   0.31967
    173.51509   0.31563
    153.65141   0.31274
    139.62999   0.31216
    EOD
    
    splot $Data using 1:2:(0) with polygon, '' using 1:2:(0) with lp lw 4
    

    enter image description here