My application is receiving data over the network at about 30fps, and needs to update a horizontal bar chart dynamically based on this new data.
I am using a matplotlib figure inside a tkinter window for this purpose. Profiling my code has shown that a major bottleneck in my code is the updating of this figure.
A simplified version of the code is given below:
def update_bars(self):
"""
Updates a horizontal bar chart
"""
for bar, new_d in zip(self.bars, self.latest_data):
bar.set_width(new_d)
self.figure.draw()
The lag I am experiencing is significant, and grows quickly over time. Is there a more efficient way to update the matplotlib figure? Any help would be great.
EDIT: I will be looking at this for possible speedup tips. I'll update if I get something working.