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

Thanks for the reply. Yes, the figure is opened immediately (or at least I think that’s what’s happening, because it’s only there for a very short time), but then closed again, right away.

import matplotlib.pyplot as plt
plt.ion()
plt.plot([0, 1], [0, 1])
# At this point, I want to view first plot, then press ESC in plot window to close it
plt.plot([0, 1], [1, 0])
# I want to view both first plot and second plot in the window now, then ESC to quit program

That’s why I said I need plt.pause. Otherwise the window is there for only a fraction of a second - also showing both plots right away.

My problems would be completely resolved by something like this:

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)

I have 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 that’s maybe possible