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

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