When it comes to graphs, gretl has a very good interface. This is why sometimes I open gretl not for another regression, but simply to create another graph. On the other hand, the default settings for graphs in gretl are a sort of “one-size-fits-all”, so I often have to fine-tune the graphs before saving them as image. The need to to repeat many steps for every single graph can be annoying — e.g. I save the graph, close gretl and then discover that the title is mis-spelt.

In order to avoid these unnecessary repetitions I looked at gnuplot. gnuplot is a plotting software that can produce very expressive graphs. Actually, it’s gnuplot that produces graphs for gretl, but calling gnuplot directly, without relying at gretl, gives us much more control over the final result.

For the sake of exersice, I used data on Moldovan consumer prices, which I use in my research, to test-drive gnuplot. A bref look at the data:

$ cat cpi_monthly.csv
1994M01,0.173112617709,0.239803992207,0.094400675421,0.358373500574
1994M02,0.195550183875,0.221537226460,0.167194062267,0.239803442394
1994M03,0.095322755336,0.094381285981,0.072302758560,0.193910185446
1994M04,0.048778187476,-0.008989342544,0.065817779879,0.151001315845
1994M05,0.026649336222,0.021757413856,0.022738045009,0.053564944099
1994M06,0.026639092138,0.035333466639,0.012894161453,0.010939501922
1994M07,0.021790046158,-0.015093378960,0.042128161494,0.073228745712
...

and so on up to December 2011.

OK, let’s plot the last eleven years.
$ gnuplot
set datafile separator ","
set xdata time
set timefmt "%YM%m"
set xrange ["2000M01":"2011M12"]
set format x "%Y"
set yr [-.05:.05]
set xzeroaxis lt 0 lw 1 linecolor rgb "black"
set style line 1 lt 1 lw 1 pt 3 linecolor rgb "blue"
set title 'CPI inflation (log monthly changes), 2000-2011'
plot "cpi_monthly.csv" using 1:2 notitle w line ls 1

Yes, if one creates graphs from time to time, then it will look like too much code. However, if one needs to produce many graphs with the same look-and-feel, one can reuse this code for multiple times, with only minor changes. Below is the result (click to enlarge).

CPI inflation (log monthly change), 2000-2011

CPI inflation (log monthly change), 2000-2011

Leave a Reply