Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/emilyhunt/SK8plotlib. Turn any matplotlib line chart into a line skateboarding game. 🛹 pypi.org/project/SK8plotlib
Something went wrong. Try again.
1.1 kB · 38 lines
Python
at commit a09fbd84
123456789101112131415161718192021222324252627282930313233343536373839import matplotlib.pyplot as pltfrom matplotlib.figure import Figureimport matplotlib
from sk8plotlib.variables import FRAMERATEfrom .matplotlib_hacks import fetch_matplotlib_datafrom .skater import Skaterfrom .camera import Camerafrom matplotlib.animation import FuncAnimation
matplotlib.use("QtAgg")
def sk8plot(fig: Figure): animator = PlotAnimator(fig) animation = FuncAnimation( fig, animator.update_animation, frames=range(100), interval=1000 / FRAMERATE ) plt.show()
class PlotAnimator: def __init__(self, fig): self.fig = fig self.ax, self.lines, self.line_data = fetch_matplotlib_data(fig)
# Some beautification fig.canvas.setWindowTitle("SK8plotlib - ollie on your data") fig.suptitle("SK8plotlib - ollie on your data")
# Make components self.skater = Skater(self.fig, self.ax, self.line_data) self.camera = Camera(self.fig, self.ax, self.skater) self.camera.move_camera()
def update_animation(self, frame): self.skater.update() self.camera.move_camera()