I've been unable to find a way of producing the plot described in the title, does anyone know how to do this if it's possible? I'd like to plot a surface from a function, and plot points from a file, and have lines drawn between the points and the surface. The link below is an image that contains an example of what I'd like to do, taken from a stackoverflow question for an identical task (but for a different plotting program).

# Best How To :

You can do the calculations inside gnuplot's `using`

statement. For the lines I use the `vectors`

plotting style, and with `arrowstyle variable`

(or `linecolor variable`

) you can select different colors depending on the `dz`

value:

```
set style arrow 1 linecolor rgb 'red' nohead
set style arrow 2 linecolor rgb 'green' nohead
splot f(x,y) with lines, \
'points.dat' using 1:2:(f($1,$2)):(0):(0):(dz=$3-f($1,$2)):(dz < 0 ? 1 : 2) with vectors arrowstyle variable,\
'' using 1:2:3 with points pt 7 ps 5
```

I'm not sure, which this gives problems with gnuplot 4.6. For your case you can also use `linecolor variable`

or `linecolor rgb variable`

to change the color of the vertical lines:

```
splot f(x,y) with lines, \
'points.dat' using 1:2:(f($1,$2)):(0):(0):(dz=$3-f($1,$2)):(dz < 0 ? 0xff0000 : 0x00ff00) with vectors nohead linecolor rgb variable lw 5,\
'' using 1:2:3 with points pt 7 ps 5
```