I have a Python code that contains a function where a figure is created in order to be saved as a pdf (it never shows on the screen during execution). For some reason, the execution of this subroutine keeps the figure open and blocks the following operations in the code. I tried to use the cla(), clf() and clear() functions but I could not get it to work...
Here is a partial view of the subroutine:
def trace_pdf(a,b,c,d):
   x = np.linspace(0,100,a)
   fig2 = plt.figure()
   ax2 = fig2.add_subplot(111)
   ax2.plot(b,c,'b', label='BA',linewidth=3.5)
   ax2.set_title('a pdf like no other')     
   fig2.savefig('file.pdf', format='pdf')       
   fig2.clf()
   fig2.clear()
I do not see why my code is blocked... (I checked that if I comment the call to the trace_pdf function, everything works fine).