I am working on a python script where I have the following method in an object Plotter :
import matplotlib.pyplot as plt
class Plotter:
def __init__(self):
self.nbfig = 0
def plot(self):
self.nbfig += 1
plt.figure(self.nbfig)
plt.plot(self.time, self.angle, 'b')
plt.ion()
plt.show()
The python script is called by a real time C++ app whenever it needs to plot something (that is why i am using plt.ion() so that the plot runs in a different thread and does not stop the c++ app) However, sometimes the c++ app needs to refresh the app and calls the following method:
def refresh(self):
if (self.nbfig > 0): #meaning the c++ app already plotted a figure
plt.close()
This method effectively close the matplotlib window where I plotted the angle. However, when it calls a second time the method plot (defined above), nothing gets plotted (an empty window appears).
It seems that calling plt.close() affects the all behaviour of matplotlib (I tried to close manually the window and the script is able to plot different graphs one after the other)
Have you ever encountered this kind of issue ?
Thanks a lot for your help
Best
Vincent