I have two functions that draw different plots, say foo1 and foo2. I added a return plt.gcf() at the end, so I have:
def foo1():
#draw plot
return plt.gcf()
def foo2():
#draw plot
return plt.gcf()
I wrote some code that saves those plots:
fig1 = foo1()
fig2 = foo2()
fig1.savefig("tmp1")
fig2.savefig("tmp2")
And it works fine, next I want to do:
fig, (fig1,fig2) = plt.subplots(ncols=2)
fig1 = foo1()
fig2 = foo2()
fig.savefig("tmp")
This is where it fails because I only get two empty plots. Is there any way to modify the last two lines of code to get my two figures to show next to each other (as in plt.subplots(ncols=2)), or at least save them in the same file?