Reference
snaplot.main.Camera
A class for capturing matplotlib figures and exporting them as a GIF.
Attributes:
Name | Type | Description |
---|---|---|
verbose |
bool
|
If True, prints log messages during execution. |
directory |
str
|
Directory path where images are stored. |
n_images |
int
|
Count of currently saved images. |
file_paths |
list
|
List of saved image file paths. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
force_new
|
bool
|
If True, clears the target directory before recording. |
False
|
dir_name
|
str
|
Subdirectory name inside ~/.snaplot to store images. |
'default'
|
verbose
|
bool
|
If True, enables logging of actions. |
True
|
snap(fig=None, extension='png', **kwargs)
Capture and save a matplotlib figure to the recording directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fig
|
Figure
|
The figure to save. If None, uses the current active figure. |
None
|
extension
|
str
|
File extension/format to save the figure (e.g., 'png', 'jpg'). |
'png'
|
**kwargs
|
Dict
|
Additional keyword arguments passed to |
{}
|
stop(path, frame_duration=100, n_repeat_last_frame=1, resolution='auto')
Compile the saved images into a GIF.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
Output path for the final GIF. |
required |
frame_duration
|
int
|
Duration of each frame in milliseconds. |
100
|
n_repeat_last_frame
|
int
|
Number of times to repeat the last frame. |
1
|
resolution
|
Union[str, Tuple, List]
|
An optional array with 2 integers (width and height, in pixels) for the resolution of the GIF. By default, it will use the dimensions of the last image in inches and convert them to pixels. |
'auto'
|