flypig.co.uk

List items

Items from the current list are shown below.

News

27 Aug 2022 : Histographs fixed #
In my last waste data report I lamented the fact that the histograph portion of my graph rendering algorithm was failing, leaving the graphs on my waste page unhelpfully blank. After much digging around in the code I eventually narrowed the problem down to the x-axis limits. Dates in python can be converted to and from ordinals. As the documentation explains, the ordinal values are "the proleptic Gregorian ordinal of the date, where January 1 of year 1 has ordinal 1". Today (27th August 2022), for example, is 738394. So it turns out that I was setting the axis limits to be dates, while the data point x values were being set as ordinals. This worked fine for matplotlib 3.1.2 on Ubuntu 20.04, but broke after upgrading to matplotlib version 3.5.1 on Ubuntu 22.04. The fix was easy once I'd figured out the cause: simply use ordinals throughout and add a custom renderer for the x-axis text so that the values are still shown as dates. Arguably it should never have worked and my original implementation was faulty, so I'm happy the code is cleaner and more correct now, but more importantly it also means my waste graphs are now shown correctly again on the waste page. And I have one less niggling annoyance to deal with occupying the back of my mind!