Matplotlib how to draw on figure on PIL image
I've got a new problem here, I 开发者_如何学Gowish to inputs a PIL image object, and then draw the figure that generated from matplotlib, and then return the PIL image object. How could I achieve this?
Why don't you create the image in matplotlib, save it and then import it into pil?
xdata = pylab.arange(1961, 2031, 1)
pylab.figure(num=None, figsize=(20.48, 10.24), dpi=100, facecolor='w', edgecolor='k')
pylab.plot(xdata, ydata, linewidth=3.0)
pylab.xlabel(xlabel)
pylab.ylabel(ylabel)
pylab.title(title)
pylab.grid(True)
ram = cStringIO.StringIO()
pylab.savefig(ram, format='png')
import Image
im = Image.open(ram.read())
精彩评论