Qplot for Gnuplot

gnuplot | qplot | operation | requirements | download | samples | utility

Gnuplot

Gnuplot is a very full-featured graphing/plotting program, with the added attractions of being free and open-source. One limitation of gnuplot from an economist's point of view is that it is not set up to handle quarterly time-series data with ease. You can plot such data OK, but it's difficult to get the time-axis tic labels to come out right (e.g. "1960.1", "1995.4"). Gnuplot actually has a sophisticated and flexible mechanism for handling time on the x-axis, but it is based on the unix time "struct", which does not recognize the quarter-year as a primitive unit of time, so you have to go through some contortions to get the labels right.

The qplot package

The little package here is designed to make the plotting of quarterly data easy. It takes the form of two files:

How it works

Here is the modus operandi:

Requirements

Downloading qplot

You can simply grab the files mentioned (and linked) above. Or you can grab a zipfile containing everything, including a copy of this page and some sample datafiles: qplot.zip. Qplot is governed by the GNU Public License.

Sample plots

These simple plots are designed to illustrate the date handling capacity of qplot.

Sample 1:

set size .8,.8
set term png color
set output "sample1.png"
set title "Gross domestic product (AR, bil. 1987 $) 1948.1 - 1993.3"
set nokey
call "qplot.gp" "q3.dat" "using 1:2 w l"
sample1.png

Sample 2:
set size .8,.8
set term gif
set rmargin 4
set output "sample2.gif"
set title "Gross domestic product (AR, bil. 1987 $) 1948.1 - 1950.4"
set nokey
call "qplot.gp" "q2.dat" "using 1:2 w l"
sample2.gif

Sample 3:
set size .8,.8
set term png color
set rmargin 4
set output "sample3.png"
set title "Gross domestic product (AR, bil. 1987 $) 1948.1 - 1950.4"
set nokey
call "qplot.gp" "q2.dat" "using 1:2 w l" 6
sample3.png

Utility

Do you have a datafile containing quarterly time series data, but without the required date markers in the first column? Here is a little perl filter that adds dates: add_quarters.pl. The useage is, for example:
add_quarters.pl 1956.1 < econ.dat
That is, supply a starting date in the form YYYY.Q (or YY.Q) and supply the name of an existing datafile on standard input: the datafile with dates added will appear on standard output.


Allin Cottrell (cottrell@ricardo.ecn.wfu.edu) May, 1999

Valid HTML 4.0!