'Speed multiple animations with matplotlib
I am working on a project (Python 3.8, PyQt5, matplotlib, numpy) in which I have two threads:
- data thread : to collect get data and optimize" the collect of data which is between 1 and 5kHz (a line of 256 float)
- gui thread : to display the last data get as fast as possible on the GUI (3 matplotlib figures)
I am also using some animations to make faster the update of data on the screen, using the following pseudocode line:
anim = animation.FuncAnimation(myFigure, updateData, interval=10, blit=False)
I have 3 figures with each 2 subplots:
- To display an image of 256x600 pixels updating only one column with the last data acquire and available
- To display the last data of 256 pixels
So today I have 3 animations, one for each figure.
The pseudo code for the update function is the following one :
def update(self, i):
# Create fake data (because the data thread is not working for now)
random = np.random.rand(256)
# Display it on the continuous graph
dataImg = np.transpose(self.imageInProgress)
dataImg[:-1] = dataImg[1:]
dataImg[-1] = random.copy()
self.imageInProgress = np.transpose(dataImg)
self.image[0].set_data(self.imageInProgress) # the image list contains all subplots (2D and 1D plots)
# Display it on the line graph
self.image[1].set_data(range(1, 257), random)
self.countIPS1 += 1
return
But doing this, I have an update of my total GUI between 5 and 10 times per second.
Is there some parameters of the animation, or anything else, which can upgrade my animation refresh?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
