Canvas
Canvas
Creates the matplotlib figure, subplots and additional figure properties. Also creates and saves the animation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nrows |
int
|
Number of rows of the subplot grid, by default 1 |
1
|
ncols |
int
|
Number of columns of the subplot grid, by default 1 |
1
|
figsize |
tuple[int, int]
|
Width, height in inches, by default (16, 9) |
(12.8, 7.2)
|
post_update |
Callable[[plt.Figure, list[list[plt.Axes]]], None]
|
callback function for additional figure customization, by default None |
None
|
post_update args:
add_plot(plot, index=(0, 0))
Adds the plot to be animated with its ax index (for multiple subplots)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
plot |
Plot_like
|
Plot to be animated |
required |
index |
tuple[int, int]
|
Subplot index, by default (0, 0) |
(0, 0)
|
Returns:
Type | Description |
---|---|
Canvas
|
Returns the canvas instance |
animate(frames_callback=lambda length: length, interval=50, **kwargs)
Main module to create the animation, additional kwargs
are passed to animation.FuncAnimation(**kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frames_callback |
int
|
Passed to funcAnimation frames, by default lambda length: length |
lambda length: length
|
interval |
int
|
Interval between each frame. Defaults to 50ms, by default 50 |
50
|
save(filename, fps, extension='gif', **kwargs)
Saves the current animation
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str
|
Filename |
required |
fps |
int
|
Video fps / frames per second |
required |
extension |
str
|
File extension, by default "gif" |
'gif'
|