gd library. gd was widely used back in the day, but looks a bit clunky now.
Here's the solution I came up with, to use SVG through PySVG. It's pure-Python and so doesn't require any extra libraries, which is always a pain when dealing with graphics.
I used the code below to generate an SVG file, which was converted to the above PNG with Inkscape:
Anyone else got any suggestions?