Created
January 18, 2024 17:55
-
-
Save danielrmeyer/ce8dada8b549c95342f25486432dac85 to your computer and use it in GitHub Desktop.
Demo how we could build a realtime polar plot with matplotlib
This file contains hidden or 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
# pip install matplotlib | |
# pip install PyQt5 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.animation import FuncAnimation | |
# Function to update the polar plot | |
def update(frame): | |
# Your streaming data source logic goes here | |
# For example, generate random data | |
theta = np.linspace(0, 2*np.pi, 100) | |
values = np.random.rand(100) | |
# Update the polar plot | |
line.set_ydata(values) | |
return line, | |
# Set up the polar plot | |
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'}) | |
theta = np.linspace(0, 2*np.pi, 100) | |
values = np.random.rand(100) | |
line, = ax.plot(theta, values) | |
# Set up the animation | |
ani = FuncAnimation(fig, update, frames=range(100), blit=True) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment