Skip to content

plot_backend

Abstract base class for visualization backends.

Defines the common interface that all visualization backends (matplotlib, TikZ, d3.js, manim) must implement. Handles plot data extraction and provides standardized save/show methods.

Example
class CustomBackend(PlotBackend):
    def save(self, filename: str) -> None:
        # Implementation for saving
        pass

    def show(self) -> None:
        # Implementation for display
        pass

PlotBackend

Abstract base class for all visualization backends.

Provides common interface for matplotlib, TikZ, d3.js, and manim backends. Extracts plot data and configuration for backend-specific rendering.

Source code in src/pathpyG/visualisations/plot_backend.py
class PlotBackend:
    """Abstract base class for all visualization backends.

    Provides common interface for matplotlib, TikZ, d3.js, and manim backends.
    Extracts plot data and configuration for backend-specific rendering.
    """
    def __init__(self, plot: PathPyPlot, show_labels: bool) -> None:
        """Initialize backend with plot data and configuration.

        Args:
            plot: PathPyPlot instance containing network data
            show_labels: Whether to display node labels
        """
        self.data = plot.data
        self.config = plot.config
        self.show_labels = show_labels

    def save(self, filename: str) -> None:
        """Save plot to file.

        Args:
            filename: Output file path

        Raises:
            NotImplementedError: Must be implemented by subclasses
        """
        raise NotImplementedError("Subclasses should implement this method.")

    def show(self) -> None:
        """Display plot on screen.

        Raises:
            NotImplementedError: Must be implemented by subclasses
        """
        raise NotImplementedError("Subclasses should implement this method.")

__init__

Initialize backend with plot data and configuration.

Parameters:

Name Type Description Default
plot pathpyG.visualisations.pathpy_plot.PathPyPlot

PathPyPlot instance containing network data

required
show_labels bool

Whether to display node labels

required
Source code in src/pathpyG/visualisations/plot_backend.py
def __init__(self, plot: PathPyPlot, show_labels: bool) -> None:
    """Initialize backend with plot data and configuration.

    Args:
        plot: PathPyPlot instance containing network data
        show_labels: Whether to display node labels
    """
    self.data = plot.data
    self.config = plot.config
    self.show_labels = show_labels

save

Save plot to file.

Parameters:

Name Type Description Default
filename str

Output file path

required

Raises:

Type Description
NotImplementedError

Must be implemented by subclasses

Source code in src/pathpyG/visualisations/plot_backend.py
def save(self, filename: str) -> None:
    """Save plot to file.

    Args:
        filename: Output file path

    Raises:
        NotImplementedError: Must be implemented by subclasses
    """
    raise NotImplementedError("Subclasses should implement this method.")

show

Display plot on screen.

Raises:

Type Description
NotImplementedError

Must be implemented by subclasses

Source code in src/pathpyG/visualisations/plot_backend.py
def show(self) -> None:
    """Display plot on screen.

    Raises:
        NotImplementedError: Must be implemented by subclasses
    """
    raise NotImplementedError("Subclasses should implement this method.")