Yesterday was my day off, and I went to Brighton on the train.

Brighton station

Of course Brighton being what it is, I saw some cool graffiti.

graffiti in a side alley

And saw a Cuban motorbike parked outside infinity foods

cool bike

And then I set up in a cafe with my laptop, to carry on learning how to use gnuplot.

I’ve revived a side-project to produce an article. The article itself is written and done, but I submitted it to a few places and got nowhere. So, my long-term plan is to rewrite it, update it to reflect more recent developments, cut it down by a few thousand words, add some graphs, and in the process get some experience in proper article publishing.

There are a few stages of production you go through when writing something. Your average university student, at least in their first year, probably starts off writing their essays in Word, or in my case Libreoffice. At the beginning you only need to reference a couple of books, and you type out the bibliography yourself at the end of the document. This quickly gets time consuming as you write longer essays with more references, and you end up using reference management software. I use Zotero standalone, and I guess other people use EndNote, or Mendeley; what these programs do is separate research sources from the content of your paper. The last natural stage is forming style templates.

Some professors are pretty lax about style rules, so long as the essay is in a readable font at a reasonable size, you can layout your essay however you like. After a couple of essays you settle on a sort of preferred layout, and you just stick with it through every essay you write. Generally people gravitate around a standard-looking essay template. Again, this separates layout concerns from the content of your paper. Ever wondered why a lot of academic papers all look kind of similar? Eventually you realise they’re all using typesetting programs, and that the ‘correct’ way to write a paper is in LaTeX, with a standard typesetting template. I’ve looked around and most academic publishers provide templates on request.

Nobody at university really teaches you these things, so I’m figuring out LaTeX for myself. The irony is, I’ve been spending my time learning how to use proper academic tools… and in doing so, I’ve neglected to do much writing. That’s ok though, so long as it’s a useful learning exercise.

Where does gnuplot sit in all this? Gnuplot generates graphs programatically, and if all goes as it should my graphs should integrate with LaTeX to generate the graph while the document is typeset. It also separates the raw data from its presentation in a document.

For this example I’ll be using the election results of the Democratic Left Alliance in Poland. Here’s the contents of my data file:

2015-10-25 7.6
2011-10-09 8.2
2007-10-19 13.2
2005-09-25 11.3
2001-09-23 41
1997-09-21 27.1
1993-09-19 20.4
1991-10-27 12

It’s just a list with the election date followed by vote share. This data is pulled from the ParlGov database.

Here’s what I pass to gnuplot to generate the graph:

set datafile separator " "
set terminal svg size 900,400
set title "Polish Democratic Left Alliance legislative election results 1991-2015"
set ylabel "vote share"
set xlabel "time"
set xdata time
set timefmt "%Y-%m-%d"
set format x "%Y"
set grid
plot "poland_election.dat" using 1:2 with linespoints lw 3 lt rgb "black" pt 7 ps 1.3 notitle

And, here’s the graph:

Polish election results

You might need to zoom in to read the text on small screens.

As you can see, the centre-left party went on a 10-year march to power from 1991 to 2002. Then, in 2002 the party was hit with two political scandals. The first scandal involved an individual requesting a bribe for legislative changes, which did not directly implicate the party, but it did damage their reputation by association. The second scandal… was something to do with an oil supply contract? In any case, according to Aleks Szczerbiak (see page 430), the scandals damaged public confidence in politicians, which in turn explains the drop in support for the then-dominant Democratic Left Alliance at the elections in 2005.