-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Animation of a clock to understand the parameters
- Loading branch information
1 parent
68d6849
commit 80a91f6
Showing
3 changed files
with
37 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import matplotlib.animation as animation | ||
|
||
|
||
fig = plt.figure(figsize=(16, 12)) | ||
ax = fig.add_subplot(111) | ||
# You can initialize this with whatever | ||
im = ax.imshow(np.random.rand(6, 10), cmap='bone_r', interpolation='nearest') | ||
|
||
|
||
def animate(i): | ||
aux = np.zeros(60) | ||
aux[i] = 1 | ||
image_clock = np.reshape(aux, (6, 10)) | ||
im.set_array(image_clock) | ||
|
||
ani = animation.FuncAnimation(fig, animate, frames=60, interval=2000) | ||
ani.save('clock.mp4', fps=1.0, dpi=200) | ||
plt.show() | ||
|
||
"""Interval is for the printing animation. So in this case, the animation that will be reproduced | ||
that is, the one that is not saved, by changing the image every 2 seconds (interval=2000 (ms))*[]: | ||
The fps (frames per second) in the other hand is for the image that will be saved. | ||
""" | ||
|
||
|
||
|
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
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