Credits Overview Plotting Styles Commands Terminals

contour

set contour enables placement of contour lines on 3D surfaces. This option is available only for splot. It requires grid data, e.g. a file in which all the points for a single y-isoline are listed, then all the points for the next y-isoline, and so on. A single blank line (containing no characters other than blank spaces) separates one y-isoline from the next. see grid_data for more details.

If the data is not already gridded, set dgrid3d can be used to first create and populate an appropriate grid.

Syntax:

      set contour {base | surface | both}
      unset contour
      show contour

The three options specify where to draw the contours: base draws the contours on the grid base where the x/ytics are placed, surface draws the contours on the surfaces themselves, and both draws the contours on both the base and the surface. If no option is provided, the default is base.

See also set cntrparam for the parameters that affect the drawing of contours, and set cntrlabel for control of labeling of the contours.

Note that this option places lines or labels without otherwise changing the appearance of the surface itself. If you want to recolor the surface so that the areas bounded by contour lines are assigned distinct colors, use instead the contourfill plot style. See contourfill.

While set contour is in effect, splot with <style> will place the style elements (points, lines, impulses, labels, etc) along the contour lines. with pm3d will produce a pm3d surface and also contour lines. If you want to mix other plot elements, say labels read from a file, with the contours generated while set contour is active you must append the keyword nocontours after that clause in the splot command.

The surface can be switched off (see unset surface) to give a contour-only graph. A 2D projection of the contour lines and optional labels can be generated by

     set view map
     splot DATA with lines nosurface, DATA with labels

Older gnuplot versions used an alternative multi-step method to save the 3D contour lines into a file or datablock and then plot them using a 2D plot command as shown below.

      set contour
      set table $datablock
      splot DATA with lines nosurface
      unset table
      # contour lines are now in $datablock, one contour per index
      plot for [level=0:*] $datablock index level with lines

See also splot datafile and demos for contours (contours.dem) and user defined contour levels (discrete.dem).