PdPlot: an X11 graphing tool for ASCII data

What is it?

Pdplot is a GPL'ed clone of Bob Jewett's autoplot(1) program popular among IC designers at HP and Agilent labs. It accepts simple "x y" data points and formatting commands from standard input, autoscales the data and plots it to an X11 window. Pdplot can dump the current graph in both postscript and PNG formats.

Usually Pdplot is invoked by the helper script pd(1) which will start a Pdplot process as a persistent graph server reading a named pipe. pd(1) then sends any standard input to the pdplot daemon for plotting.

Example usage:

Here's an example of how pd can plot a data file, add data to an existing plot and then dump the resulting plot to either postscript or png.
    echo "title sample plot\n0 0\n1 1" > data	; make a data file
    cat data | pd 				; plot it
    echo "title sample plot\n0 1\n1 0" > data2	; make another data file
    cat data2 | pd -n				; add it to the same plot

    pd -p data12				; dump postscript of 
						; current plot to "data12.ps"

    pd -g data12				; dump compressed png bitmap of 
						; current plot to "data12.png"

It makes pretty good plots even without any formatting commands, and can bang out sophisticated multi-graph plots without much effort. It excels at plotting the output of perl or awk scripts when munging through SPICE data files.

It's a matter of taste, but for many tasks Pdplot is arguably more convenient to use than gnuplot for interactive data visualization because it is optimized for reading data produced on the fly, instead of formatted data files. In addition, pdplot's architecture reuses the same persistant graph window, either erasing the data or adding new data as requested. This produces a lot less desktop clutter than creating a new window for each graph.

Examples

Here's an awk program for making a simple plot of a sine wave:


awk ' BEGIN {
      print "title sine wave"	# title
      print "xscale 1 time"	# x,y scale factors and legends
      print "yscale 1 value"	
      for (t=0; t<=3; t+=.01) {
         print t, sin(2*3.14159*t)
      }				# data as ASCII x y pairs, one per line
      print "graph example"	# make a png dump of the graph in example.png
} ' | pd

Notice that the output of the script is piped directly into pd, which immediately pops up a graphic window if one didn't already exist. By using the "graph example" command, pd will automatically dump the plot to the file "example.png". Here's the resulting output. (Click on the thumbnail for a full-sized image):