def myplot(t, x):
    fig = figure()
x = plot(t, x)
fig.savefig('plot.png')
return fig
t = arange(0, 6, 0.01)
x = sin(t)
f = myplot(t, x)
How to have a function return a figure in python (using matplotlib)?