Plots module

KoswatFigureContextHandler

PyPlot fig context handler that opens the figure stream and closes it saving it to the appointed path.

Usage example

with KoswatFigureContext(Path("C://my_plot.png"), 42) as _figure: _subplot = _figure.add_subplot() ...

__enter__() -> Figure

Access to the context and invokation of pyplot.figure(dpi).

Returns:

Name Type Description
Figure Figure

Initialized instance from pyplot.figure(dpi=dpi).

__exit__(*args, **kwargs) -> None

Exit the current context and save the previously initialized Figure.

__init__(output_path: Path, dpi: int) -> None

Initializes the context by invoking pyplot.figure(dpi=dpi) and saving its output to an internal field.

Parameters:

Name Type Description Default
output_path Path

Export location for the generated plot.

required
dpi int

Canvas resolution in dots-per-inch.

required

KoswatPlotProtocol

Bases: Protocol

plot(*args, **kwargs) -> pyplot.axes

Plots a koswat_object into the provided plot ax with the requested *args and **kwargs.

Returns:

Type Description
pyplot.axes

pyplot.axes: Canvas with plotted koswat_object.

KoswatExporterProtocol

Bases: Protocol

export(**kwargs) -> None

Exports an object model into a concrete file format.

PlotExporterProtocol

Bases: KoswatExporterProtocol, Protocol

export() -> None

Exports a given object into a plot.