Last active
June 30, 2023 06:00
-
-
Save ugo-nama-kun/9e16baa672d5e3b466d9100be5d8a879 to your computer and use it in GitHub Desktop.
Online Plotting with Matplotlib
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 | |
from collections import deque | |
plt.figure() | |
ax = plt.subplot(1,1,1) | |
plt.ylim([-1.1, 1.1]) | |
plt.xlim([0, 50]) | |
# data | |
data = deque([0]*50, maxlen=50) | |
lines = plt.plot(data) | |
for i in range(1000): | |
new = 2 * np.random.rand() - 1 | |
data.append(new) | |
# Plotting | |
lines[0].set_ydata(data) | |
plt.pause(0.1) # drawing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements: matplotlib, numpy