Why does plt.show clear all figures? How to avoid that?

Thanks for the reply. I’m not using Spyder or IPython console. For me, if I run the aforementioned code from my terminal, the plot window pops up for the fraction of a second and that’s it. Which makes me think that interactive mode plt.ion() either needs something extra that I haven’t figured out yet, or it’s not suitable in my case.

However, as mentioned above, I was thinking that something like

import matplotlib.pyplot as plt
# plt.ion()  # no interactive mode
plt.plot([0, 1], [0, 1])
plt.show(clear_figures=False)
plt.plot([0, 1], [1, 0])
plt.show(clear_figures=False)

should solve the issue and I have therefore opened a new thread https://discourse.matplotlib.org/t/feature-request-plt-show-clear-figures-false-new-keyword-argument-clear-figures-to-avoid-figures-being-cleared-by-plt-show/ to see if it’s possible to add this feature.