Created
February 5, 2021 11:07
-
-
Save anupam-io/5526cbda42199ae74412fa663d8d30bc to your computer and use it in GitHub Desktop.
Live animation from X and Y values in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
import time | |
from random import randint | |
n = 10 | |
x = [] | |
y = [] | |
plt.ion() | |
fig = plt.figure(figsize=(8, 6)) | |
for _ in range(n*n): | |
# Here you can update values of X and Y | |
x = [randint(1, n) for i in range(n)] | |
y = [randint(1, n) for i in range(n)] | |
plt.cla() | |
plt.scatter(x, y) | |
fig.canvas.draw() | |
fig.canvas.flush_events() | |
time.sleep(0.3) # Waiting for some time to start the next iteration |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment