SpyllingFigure#
- class spylt.SpyllingFigure(*args, plot_fun: function | module | None = None, data: dict[str, Any] | None = None, as_dir: bool = True, zipped: bool = False, excluded_args: Iterable | None = None, excluded_types: Iterable | None = None, save_env: bool = False, verbose: bool = False, **kwargs)[source]#
Bases:
FigureFigure subclass that will backup data to disk on save.
- Parameters:
- *args
matplotlib.figure.Figureinit arguments.- plot_fun
Function or method used to generate the figure.
- data
Dictionary containing all the data objects necessary to reproduce the figure with plot_fun.
- as_dir
Whether to save the backup in a child directory, named after the figure file’s name.
- zipped
Whether to save the backup in a zipped directory, named after the figure file’s name. If as_dir is True too, only a zip will be saved.
- excluded_args
Iterable of argument names not to save even if they are present in data.
- excluded_types
Iterable of argument types not to save even if they are present in data.
- save_env
Whether to save a file listing the packages installed in the virtual environment (requirements.txt for pip, environment.yml for conda).
- verbose
Whether to print for every file saved to disk.
- **kwargs
matplotlib.figure.Figureinit keyword arguments.
- savefig(*args, **kwargs)[source]#
This extended version also backs up the data needed to reproduce this figure.
Save the current figure.
Call signature:
savefig(fname, *, dpi='figure', format=None, metadata=None, bbox_inches=None, pad_inches=0.1, facecolor='auto', edgecolor='auto', backend=None, **kwargs )
The available output formats depend on the backend being used.
- Parameters:
- fnamestr or path-like or binary file-like
A path, or a Python file-like object, or possibly some backend-dependent object such as matplotlib.backends.backend_pdf.PdfPages.
If format is set, it determines the output format, and the file is saved as fname. Note that fname is used verbatim, and there is no attempt to make the extension, if any, of fname match format, and no extension is appended.
If format is not set, then the format is inferred from the extension of fname, if there is one. If format is not set and fname has no extension, then the file is saved with :rc:`savefig.format` and the appropriate extension is appended to fname.
- Other Parameters:
- dpifloat or ‘figure’, default: :rc:`savefig.dpi`
The resolution in dots per inch. If ‘figure’, use the figure’s dpi value.
- formatstr
The file format, e.g. ‘png’, ‘pdf’, ‘svg’, … The behavior when this is unset is documented under fname.
- metadatadict, optional
Key/value pairs to store in the image metadata. The supported keys and defaults depend on the image format and backend:
‘png’ with Agg backend: See the parameter
metadataof ~.FigureCanvasAgg.print_png.‘pdf’ with pdf backend: See the parameter
metadataof ~.backend_pdf.PdfPages.‘svg’ with svg backend: See the parameter
metadataof ~.FigureCanvasSVG.print_svg.‘eps’ and ‘ps’ with PS backend: Only ‘Creator’ is supported.
- bbox_inchesstr or .Bbox, default: :rc:`savefig.bbox`
Bounding box in inches: only the given portion of the figure is saved. If ‘tight’, try to figure out the tight bbox of the figure.
- pad_inchesfloat, default: :rc:`savefig.pad_inches`
Amount of padding around the figure when bbox_inches is ‘tight’.
- facecolorcolor or ‘auto’, default: :rc:`savefig.facecolor`
The facecolor of the figure. If ‘auto’, use the current figure facecolor.
- edgecolorcolor or ‘auto’, default: :rc:`savefig.edgecolor`
The edgecolor of the figure. If ‘auto’, use the current figure edgecolor.
- backendstr, optional
Use a non-default backend to render the file, e.g. to render a png file with the “cairo” backend rather than the default “agg”, or a pdf file with the “pgf” backend rather than the default “pdf”. Note that the default backend is normally sufficient. See The builtin backends for a list of valid backends for each file format. Custom backends can be referenced as “module://…”.
- orientation{‘landscape’, ‘portrait’}
Currently only supported by the postscript backend.
- papertypestr
One of ‘letter’, ‘legal’, ‘executive’, ‘ledger’, ‘a0’ through ‘a10’, ‘b0’ through ‘b10’. Only supported for postscript output.
- transparentbool
If True, the Axes patches will all be transparent; the Figure patch will also be transparent unless facecolor and/or edgecolor are specified via kwargs.
If False has no effect and the color of the Axes and Figure patches are unchanged (unless the Figure patch is specified via the facecolor and/or edgecolor keyword arguments in which case those colors are used).
The transparency of these patches will be restored to their original values upon exit of this function.
This is useful, for example, for displaying a plot on top of a colored background on a web page.
- bbox_extra_artistslist of ~matplotlib.artist.Artist, optional
A list of extra artists that will be considered when the tight bbox is calculated.
- pil_kwargsdict, optional
Additional keyword arguments that are passed to PIL.Image.Image.save when saving the figure.