Abstract class for assemblig plots.
Attributes
data : dict
data of the plot object
config : dict
configuration for the plot
Source code in src/pathpyG/visualisations/plot.py
| class PathPyPlot:
"""Abstract class for assemblig plots.
Attributes
----------
data : dict
data of the plot object
config : dict
configuration for the plot
"""
def __init__(self) -> None:
"""Initialize plot class."""
logger.debug("Initalize PathPyPlot class")
self.data: dict = {}
self.config: dict = {}
@property
def _kind(self) -> str:
"""Specify kind str. Must be overridden in child class."""
raise NotImplementedError
def generate(self) -> None:
"""Generate the plot."""
raise NotImplementedError
def save(self, filename: str, **kwargs: Any) -> None:
"""Save the plot to the hard drive."""
_backend: str = kwargs.pop("backend", self.config.get("backend", None))
plot_backend = _get_plot_backend(_backend, filename)
plot_backend.plot(deepcopy(self.data), self._kind, **deepcopy(self.config)).save(filename, **kwargs)
def show(self, **kwargs: Any) -> None:
"""Show the plot on the device."""
_backend: str = kwargs.pop("backend", self.config.get("backend", None))
plot_backend = _get_plot_backend(_backend, None)
plot_backend.plot(deepcopy(self.data), self._kind, **deepcopy(self.config)).show(**kwargs)
|
__init__
Initialize plot class.
Source code in src/pathpyG/visualisations/plot.py
| def __init__(self) -> None:
"""Initialize plot class."""
logger.debug("Initalize PathPyPlot class")
self.data: dict = {}
self.config: dict = {}
|
generate
Generate the plot.
Source code in src/pathpyG/visualisations/plot.py
| def generate(self) -> None:
"""Generate the plot."""
raise NotImplementedError
|
save
Save the plot to the hard drive.
Source code in src/pathpyG/visualisations/plot.py
| def save(self, filename: str, **kwargs: Any) -> None:
"""Save the plot to the hard drive."""
_backend: str = kwargs.pop("backend", self.config.get("backend", None))
plot_backend = _get_plot_backend(_backend, filename)
plot_backend.plot(deepcopy(self.data), self._kind, **deepcopy(self.config)).save(filename, **kwargs)
|
show
Show the plot on the device.
Source code in src/pathpyG/visualisations/plot.py
| def show(self, **kwargs: Any) -> None:
"""Show the plot on the device."""
_backend: str = kwargs.pop("backend", self.config.get("backend", None))
plot_backend = _get_plot_backend(_backend, None)
plot_backend.plot(deepcopy(self.data), self._kind, **deepcopy(self.config)).show(**kwargs)
|