data = []
for line in xy_data:
    data += line
img.putdata(data)
draw = ImageDraw.Draw(img)
draw.text((5, 0), title, font=font, fill=(0, 0, 0))
img.save('titled_plot.png')
Automate png formatting with python