Skip to content

D3. A surface ​

Goal: the same field as a surface in 3D, its height the value, seen from an angle.

gnuplot
# the same field as a surface: a mesh of its grid lines, hidden lines removed
set terminal svg size 600,420
set output 'pd03.svg'
set view 55, 35
set hidden3d
set xlabel 'x'; set ylabel 'y'; set zlabel '{/Symbol f}'
set ticslevel 0
splot 'field.dat' using 1:2:3 with lines title '{/Symbol f}(x,y)'
pd03
open SVG ↗

Why it works ​

  • splot reads the grid's blocks as the lines of a mesh: with lines draws its two families of grid lines.
  • set view 55, 35 turns the view: the rotation about the x axis, then about the vertical; set view 60, 30 is gnuplot's default.
  • set hidden3d removes the lines behind the surface, gnuplot's way: the top of the mesh in one color, its underside in another.
  • set ticslevel 0 puts the base at the lowest z (gnuplot's default lifts the surface over the base).

Try this ​

  • set dgrid3d 30,30 qnorm 2 before plotting scattered points: they are gridded first, then drawn as a surface.
  • From Fortran: call fig%splot(x, y, z) with a grid, then set_view and set_hidden3d.
  • set view equal xyz: the axes at their true lengths.

Pitfalls ​

  • A file without the blank lines between rows is a cloud of points, not a grid: splot then draws lines along the file order. Write the blank lines, or grid it with set dgrid3d.
  • set hidden3d needs a grid; it does not apply to scattered points.

Reference: 3D plots, 3D views. Next: D4. Colored and lit surfaces.

foresight is available under your choice of license: GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT (License).