Appendix C. Surface and contour plots


The plot command discussed in this book creates graphs that show how one variable (y) behaves as a function of another one (x). But what if you want to show how some quantity depends on two independent variables? In other words, how can you best visualize a single “output” variable as a function of two “input” variables? That’s basically the problem cartographers have: show a quantity (the elevation above sea level or the type of ground cover) as a function of two coordinates (the position on the surface). In gnuplot, you have essentially the same options cartographers have:

  • Create a rendering of a raised surface. Cartographers call this a relief map; I’ll refer to it as a surface plot.
  • Create a contour plot by looking straight down onto the coordinate plane and using contour lines (similar to the ones found on topographic maps) to indicate the elevation (or whatever the dependent variable represents).
  • Use color to create a false-color plot (what is colloquially known as a heatmap).

Surface and contour plots are treated in this appendix; false-color plots are the topic of appendix D. Surface and contour plots are created using gnuplot’s splot command (short for “surface plot”). It’s a close relative of the familiar plot command; most of what you already know will carry over directly.

C.1. Surface plots

C.2. View point and coordinate axes

C.3. Contour lines and contour plots

C.4. Plotting data from a file using splot

C.5. Smooth surfaces