Trying to be short and fast . I have a scatter plot I want to do in a for loop in live. So I have this :
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
import random
import time
x = range(1000,12000,100)
sample = random.sample(range(110),110)
plt.style.use("seaborn")
t_start = time.time()
for idx,measurement in enumerate(sample):
plt.scatter(x[idx],measurement , color='black')
print('Mean Frame Rate: %.3gFPS' % ((idx + 1) / (time.time() - t_start)))
plt.pause(0.05)
plt.show()
It is actually working but it's getting slower and slower when I get to high x . And actually it's not very aesthetic for a live plot of measurement i think.
I know people uses blit() or animation.FuncAnimation() but honestly I tried and think it's not working in my case with only this kind of data .
[EDIT]
When i say it's slowing down when I get to high x , my fps is droping from 30 at start to 5-6 at the end . I read here super_solution the same problem but couldn't apply the solution ...