Examples

PNG

---
format: revealjs
---

## Animated scatterplot

Move to the next slide to see the transitions.

```{python}
# | output: asis
import matplotlib.pyplot as plt
from pyfragments.png import AnimatedFigure

with AnimatedFigure() as ani:
    plt.xlim(-1, 3)
    plt.ylim(-1, 3)
    for i in range(3):
        with ani.fragment():
            plt.scatter(i, i, s=200)
```

SVG

---
format: revealjs
---

## Animated scatterplot

Move to the next slide to see the transitions.

```{python}
from matplotlib.figure import Figure
from pyfragments.svg import animate

fig = Figure()
ax = fig.add_subplot()
for i in range(3):
    ax.scatter(i, i, s=200, gid=".fragment")

animate(fig)
```

---

## Animated images

Move to the next slide to see the transitions.

```{python}
#| output: asis
import matplotlib
import numpy as np
rng = np.random.default_rng(0)

matplotlib.rc("image", composite_image=False)

fig = Figure()
ax = fig.add_subplot()
for i in range(3):
    ax.imshow(rng.random((10, 10)), gid=".fragment")
animate(fig)
```