I found the answer using this link
view and then close the figure automatically in matplotlib?
Essentially, here's the answer:
plt.show(block=False) # block = False allows automatic closing of the image
# the following command will close the graph in 3 seconds
time.sleep(3)
plt.close()