Skip to content

Commit 4e225cf

Browse files
committed
remove snake, update docstrings
1 parent b1c3622 commit 4e225cf

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

WrightTools/artists/_animate.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from ._helpers import norm_from_channel
1212
from ._interact import interact2D_fig
13+
from ._quick import ChopHandler
14+
1315

1416
__all__ = ["animate2D", "animate_interact2D"]
1517
logger = logging.getLogger("animation")
@@ -20,7 +22,6 @@ def animate2D(
2022
norm=None,
2123
channel=0,
2224
cmap=None,
23-
snake: bool = False,
2425
back_and_forth: bool = False,
2526
**ani_kwargs,
2627
):
@@ -46,6 +47,10 @@ def animate2D(
4647
cmap: str or Colormap (optional)
4748
colormap used. Defaults to WrightTools default
4849
50+
back_and_forth: bool = False
51+
when True, the animation will go in reverse after going forward,
52+
creating a continuous loop when repeat is no
53+
4954
**kwargs: dict items
5055
all extra kwargs are passed to matplotlib.FuncAnimation
5156
@@ -57,20 +62,21 @@ def animate2D(
5762
ani = wt.artists.animate2D(
5863
d, cmap="bwr", norm=norm, interval=100
5964
)
65+
```
66+
The animation has write to file utilities like `to_html5_video`:
67+
```
6068
with open(f"{d.natural_name}_animation.html", "w") as f:
6169
f.write(ani.to_html5_video())
62-
ani.pause() # if you use interactive viewer after, animation will loop unless you pause
70+
```
71+
Alternatively, you can show in the interactive viewer and watch the animation:
72+
```
73+
plt.show()
6374
```
6475
For colorbar normalized at each frame, you can use `functools.partial`:
6576
```
6677
from functools import partial
6778
norm = partial(CenteredNorm, vcenter=0) # halfrange evaluated for each frame
6879
```
69-
70-
Notes
71-
-----
72-
73-
snake, back_and_forth are not yet implemented
7480
"""
7581

7682
channel = data.get_channel(channel)
@@ -124,17 +130,18 @@ def updater(frame):
124130
)
125131

126132

127-
def animate_quick2D(quick2D: plt.Figure, snake=False, back_and_forth=False, **kwargs):
133+
def animate_quick2D(quick2D: ChopHandler, snake=False, back_and_forth=False, **kwargs):
128134
"""animate a quick2D series"""
135+
# define a slightly different plotter that reuses the same figure axes
136+
137+
129138
raise NotImplementedError
130139

131140

132-
def animate_interact2D(interact2D: interact2D_fig, snake=False, back_and_forth=False, **kwargs):
141+
def animate_interact2D(interact2D: interact2D_fig, back_and_forth=False, **kwargs):
133142
"""
134143
Take an interact2D figure and create an animation by moving the sliders.
135144
136-
Note: snake, back_and_forth are not yet implemented
137-
138145
"""
139146

140147
def update(frame):

0 commit comments

Comments
 (0)