Skip to content

Latest commit

 

History

History
90 lines (62 loc) · 2.29 KB

File metadata and controls

90 lines (62 loc) · 2.29 KB

plotting_backends

plotting dispatch backends

Installation

PyPI platforms PyPI version

pip install plotting_backends

Documentation

The plotting_backends library provides a set of classes that can be used for dispatching plotting functions to different backends.

The common base class is AbstractPlottingBackend and the pre-defined backends are:

  • MatplotlibBackend
  • SeabornBackend
  • PlotlyBackend
  • BokehBackend
  • AltairBackend
  • GGPlotBackend

Using with functools.singledispatch

This shows how to use plotting_backends with functools.singledispatch.

import plotting_backends
from functools import singledispatch


@singledispatch
def plotting_func(
    backend: type[plotting_backends.AbstractPlottingBackend], x: Any, y: Any
) -> None: ...


@plotting_func.register
def matplotlib(
    backend: type[plotting_backends.MatplotlibBackend], x: Any, y: Any
) -> None: ...

Using with plum (multiple dispatch)

This example shows how to use plotting_backends in conjunction with plum, a multiple dispatch library.

import plotting_backends
from plum import dispatch


@dispatch.abstract
def plotting_func(
    backend: type[plotting_backends.AbstractPlottingBackend], x: Any, y: Any
) -> None: ...


@dispatch
def plotting_func(
    backend: type[plotting_backends.MatplotlibBackend], x: Any, y: Any
) -> None: ...

Development

Actions Status ruff status

We welcome contributions!