11"""helpers for making animations"""
22
3-
43import matplotlib .pyplot as plt
54import numpy as np
65
98
109from ._interact import interact2D_fig
1110
12-
1311__all__ = ["animate2D" , "animate_interact2D" ]
1412
1513
@@ -18,8 +16,8 @@ def animate2D(
1816 norm ,
1917 channel = 0 ,
2018 cmap = None ,
21- snake :bool = False ,
22- back_and_forth :bool = False ,
19+ snake : bool = False ,
20+ back_and_forth : bool = False ,
2321 ** ani_kwargs ,
2422):
2523 """
@@ -29,25 +27,25 @@ def animate2D(
2927
3028 Parameters
3129 ----------
32-
30+
3331 data: WrightTools.data
3432 dataset to animate. take the last two axes as the ones that are plotted;
3533 other axes compose the frames of the animation
36-
34+
3735 norm: Normalize instance or callable
38- determines the normalization rules to follow.
36+ determines the normalization rules to follow.
3937 If channel is signed, defaults to CenteredNorm with null center.
4038 If channel is unsigned, defaults to Normalize from null to max.
4139
4240 channel: string, index, or Channel
4341 Select which channel to plot
44-
42+
4543 cmap: str or Colormap (optional)
4644 colormap used. Defaults to WrightTools default
4745
4846 **kwargs: dict items
4947 all extra kwargs are passed to matplotlib.FuncAnimation
50-
48+
5149 Example
5250 -------
5351 General usage (create an animation procedure and then write to file):
@@ -67,15 +65,19 @@ def animate2D(
6765
6866 Notes
6967 -----
70-
68+
7169 snake, back_and_forth are not yet implemented
7270 """
7371
7472 channel = data .get_channel (channel )
7573
7674 # initialize canvas
7775 fig , ax = plt .subplots (subplot_kw = dict (projection = "wright" ), dpi = 140 , layout = "constrained" )
78- art = ax .pcolormesh (data [tuple ([0 for i in data .shape [:- 2 ]])], cmap = cmap , norm = norm () if callable (norm ) else norm )
76+ art = ax .pcolormesh (
77+ data [tuple ([0 for i in data .shape [:- 2 ]])],
78+ cmap = cmap ,
79+ norm = norm () if callable (norm ) else norm ,
80+ )
7981 colorbar = fig .colorbar (art , ax = ax )
8082 colorbar .set_label (channel .label )
8183
0 commit comments