Skip to content

Commit 0b21fb5

Browse files
committed
docs: update readme
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
1 parent 2cbf974 commit 0b21fb5

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align='center'> plotting_backends </h1>
2-
<h3 align="center">Plotting dispatch backends</h3>
2+
<h3 align="center"> plotting dispatch backends </h3>
33

44
## Installation
55

@@ -10,24 +10,48 @@
1010
pip install plotting_backends
1111
```
1212

13-
## Documentation
13+
## Examples
1414

15-
### Getting Started
15+
### `functools.singledispatch`
16+
17+
This shows how to use `plotting_backends` with `functools.singledispatch`.
18+
19+
```python
20+
import plotting_backends
21+
from functools import singledispatch
22+
23+
24+
@singledispatch
25+
def plotting_func(
26+
backend: type[plotting_backends.AbstractPlottingBackend], x: Any, y: Any
27+
) -> None: ...
28+
29+
30+
@plotting_func.register
31+
def matplotlib(
32+
backend: type[plotting_backends.MatplotlibBackend], x: Any, y: Any
33+
) -> None: ...
34+
```
35+
36+
### `plum` (multiple dispatch)
37+
38+
This example shows how to use `plotting_backends` in conjunction with `plum`, a
39+
multiple dispatch library.
1640

1741
```python
1842
import plotting_backends
19-
import plum
43+
from plum import dispatch
2044

2145

2246
@dispatch.abstract
2347
def plotting_func(
24-
backend: plotting_backends.AbstractPlottingBackend, x: Any, y: Any
48+
backend: type[plotting_backends.AbstractPlottingBackend], x: Any, y: Any
2549
) -> None: ...
2650

2751

2852
@dispatch
2953
def plotting_func(
30-
backend: plotting_backends.MatplotlibBackend, x: Any, y: Any
54+
backend: type[plotting_backends.MatplotlibBackend], x: Any, y: Any
3155
) -> None: ...
3256
```
3357

0 commit comments

Comments
 (0)