Skip to content

Commit

Permalink
Add animation example
Browse files Browse the repository at this point in the history
  • Loading branch information
baskrahmer committed May 13, 2024
1 parent f303fda commit 7f3792c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions examples/image/matplotlib_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Example using animations
===============================
"""
# %%
# Example of making sliders in Matplotlib (source: https://sphinx-gallery.github.io/stable/auto_examples/plot_8_animations.html)

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

# Adapted from
# https://matplotlib.org/gallery/animation/basic_example.html


def _update_line(num):
line.set_data(data[..., :num])
return (line,)


fig, ax = plt.subplots()
data = np.random.RandomState(0).rand(2, 25)
(line,) = ax.plot([], [], "r-")
ax.set(xlim=(0, 1), ylim=(0, 1))
ani = animation.FuncAnimation(fig, _update_line, 25, interval=100, blit=True)

0 comments on commit 7f3792c

Please sign in to comment.