-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
67 additions
and
39 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ docs/source/*.html | |
|
||
*.gif | ||
*.mp4 | ||
*.webm | ||
|
||
**/.DS_Store | ||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,24 +1,34 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
from pyrecorder.converters.matplotlib import Matplotlib | ||
from pyrecorder.recorder import Recorder | ||
from pyrecorder.writers.gif import GIF | ||
from pyrecorder.writers.video import Video | ||
|
||
# create a writer object (here, mp4) | ||
writer = Video("video.mp4") | ||
# initialize the converter which is creates an image when `record()` is called | ||
converter = Matplotlib() | ||
|
||
writer = GIF("github.gif") | ||
writer = GIF("medium2.gif", duration=0.5) | ||
|
||
# use the with statement to close the recorder when done | ||
with Recorder(writer) as rec: | ||
rec = Recorder(writer, converter=converter) | ||
|
||
# record 10 different snapshots | ||
for t in range(10): | ||
for t in range(50): | ||
|
||
# create the plot (here, using matplotlib) | ||
X = np.random.random((50, 2)) | ||
plt.scatter(X[:, 0], X[:, 1], facecolor="none", edgecolor="red") | ||
# let us create a local figure object with two sub figures | ||
fig, (ax1, ax2) = plt.subplots(2, figsize=(3, 4)) | ||
|
||
# use the record to store the current plot | ||
rec.record() | ||
X = np.random.random((100, 2)) | ||
ax1.scatter(X[:, 0], X[:, 1], color="green") | ||
|
||
X = np.random.random(5) | ||
ax2.pie(X) | ||
# ax2.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle. | ||
|
||
# fix the size of figure and legends | ||
fig.tight_layout() | ||
|
||
# take a snapshot the specific figure object with the recorder | ||
rec.record(fig=fig) | ||
|
||
|
||
rec.close() |
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