In this note I will illustrate a quick and dirty way to construct a “fence plot” from a collection of 2d datasets. A more sophisticated approach to fence plots, with somewhat nicer output, can be found here. I offer this example as a very simple, easily understood, and easily modified alternative technique.
Here is a little gnuplot script that plots three curves in the form of a fence plot:
The graph that this creates is reproduced below. The three segments are the three sin2 functions plotted in the last line of the script, offset from each other by an arbitrary amount, in the usual manner of this kind of plot.
The function yf defined in the script, using gnuplot’s convenient ternary notation, is a trick to “blank out” the part of the surface that is not near the line y = a, leaving us with something that will look like a 2d curve. Then using a combination of impulses and a thick linewidth fills in the curves, forming the fences. If you prefer more of a picket fence look, you can decrease the linewidth or the sample frequency.
Let’s say you have a collection of files containing 2d data, rather than a set of functions to plot. If they are named in some rational way using filenames with an embedded number, you can use one of gnuplot’s simple looping constructs to read the files and make the fence plot. This script will produce a plot similar to the one above, if your data is stored in files called “file0”, “file1”, etc.:
I ran my scripts under gnuplot 4.4.3; earlier versions might not work; the looping syntax, for example, is fairly recent.