Graphical Timetables

An Eccentric Anomaly: Ed Davies's Blog

I think graphical user interfaces should have more graphs both in the sense of x-y plots (and similar) and also in the more-mathematical sense of nodes and edges.

Public transport timetables are usually fine for simple cases were you just want to use a single service to get to a place by a given time (or away from somewhere as soon as possible after a time). But, as soon as you want to do more complicated things with multiple trips like making connections or spending a certain amount of time in a place before returning (for shopping, say) they can get quite difficult to read, particularly when you don't just have paper but rather a modal user interface which makes flipping between various lists more complicated than it would be with paper.

So, for a while I've been thinking that a time-and-march style graph of services might be easier to use in some cases. Here's one for some of the buses between Dunbeath, Wick and Thurso. It's a bit of a mix of Monday's, Tuesday's and today's timetables and I didn't bother with some buses which weren't of interest to me so it should only really be taken as an illustration of the idea.

Buses (mostly nos 75, 175 and X99) generally run from Dunbeath to Wick (the X99's the Inverness bus). Some then go on to Thurso. The 82 shuttles backwards and forwards between Thurso and Wick. There are multiple stops in Wick but the two main ones for interchange are the Town Hall (which I call Wick TH here) and the High School (HS). The High School is only really of interest because the Journey Planner sometimes recommends it as a place to change buses, sometimes sensibly, sometimes less so.

I created a simple data file (2022-10-03.txt) by first asking Stagecoach's Bus Journey Planner for trips between Dunbeath and Thurso and vice-versa. I then added some more by asking for Dunbeath-Wick and Wick-Thurso (and v-v) trips.

The first line lists the places we're dealing with and specifies the order they're to be displayed. Stanzas between blank lines are individual trips, which might include multiple busses where the Journey Planner has recommended that and I've felt like it. The fields are the time and place of a stop, the bus number (inherited from the previous line if not given) and a comment which I might get round to showing as “hover text” later.

Piping this into a little Python script ( produces the following SVG graph:

In case it's not obvious, time goes down the graph, space (in a generally northerly direction) goes across. The High School is sometimes visited by buses going to and from the town centre (“Town Hall”) in both directions so there's no unique place to put it in the graph order hence the lines zigging back on their normal zags. Northbound buses are blue, southbound red.

On Monday I caught the 09:50 75 to Wick then had an hour to fill before the 11:30 82 to Thurso. I had a quick visit to the bank then a walk round the harbour. I caught the 82 to Thurso and arrived at 12:16, all very straight forward.

Coming back, I caught the 14:30 82 which arrived at Wick High School at 15:15. If I'd followed the Journey Planner's advice I'd have got out there then spent 25 minutes standing in a rather bleak and wind-swept car park until the 15:40 175 turned up.

Instead, I took a bit of a punt and stayed on the bus, got off at the Co-op, bought a chocolate bar and some bananas, then walked into the town centre to intercept the 175 there. This had the advantage of chocolate and bananas, being more sheltered from the wind and less visually tedious, and grabbing a seat before all the kids got on at the High School.

It was a bit of a punt as I assumed the 175 came through the town centre first but wasn't completely sure as the Journey Planner had, reasonably enough, not thought it necessary to complicate things by offering that option. I added the extra details of its journey after I got home.

Yesterday I decided to skip all the hanging around in Wick and aimed to take the 13:47 X99 which would take me directly to Thurso with the option of getting the 16:30 or 16:43 buses back to Wick. I was out and in sight of the bus stop 3 minutes before it was due and waited till 20 minutes after it should have been there without seeing any bus at all. Less than entirely impressed.

This graphing is something I intend to look into a bit more. First job, though will be automating the extraction of the timetable information. Fortunately, Stagecoach are nice and publish this in an open, if somewhat complicated, format: Creating the SVG in the browser might be better, too, allowing more dynamic choice of the stops of interest and so on. Maybe an exercise to learn Elm.