I read a lot of stack overflow questions regarding this topics but after a lot of experiment I can't figure out my problem.
I use PyCharm 2016.3.2 on Windows 7 (but I have the same issue on OSX), my interpreter is the last version of Anaconda with Python 3.6 and matplotlib 2.0.0.
Here is what I try to achieve (and maybe I am not using the right approach because I am trying to recreate the behavior I am use to in Octave/Matlab) :
- Plot one figure in a popup windows
- Pause my script (input("press a key to continue"))
- Observe the figure, then press a key to continue the script
- Compute something else
- Plot new data on the same figure
- Pause my script (input("press a key to continue"))
- Observe the figure, then press a key to continue the script
Here is my test code :
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
print('Plotting Data...')
plt.ion()
plt.figure(1)
plt.plot([1, 5, 10, 20], [1, 5, 10, 20])
plt.xlabel('x label')
plt.ylabel('y label')
plt.show()
plt.pause(0.0001)
input('Plotting Data done..., Press a key to continue')
plt.figure(1)
plt.plot([1, 5, 10, 20], [2, 10, 20, 40])
plt.show()
plt.pause(0.0001)
input('Program paused. Press enter to end.\n')
This is the closest version of what I want, the plots are correct but not responsive when I mouse over them (plt.pause(0.0001) generates a warning but code works).
I played a lot with parameters (plt.ion() ; plt.pause() ; plt.show(block=False)). Most of the time, this led to empty plot windows or I needed to close the window to continue the execution.
Thanks for your help !