Skip to content

Instantly share code, notes, and snippets.

@danielrmeyer
Created January 18, 2024 17:55
Show Gist options
  • Save danielrmeyer/ce8dada8b549c95342f25486432dac85 to your computer and use it in GitHub Desktop.
Save danielrmeyer/ce8dada8b549c95342f25486432dac85 to your computer and use it in GitHub Desktop.
Demo how we could build a realtime polar plot with matplotlib
# 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