55
66Inspired by https://twitter.com/_brohrer_/status/1584681864648065027
77
8+ An animated scatter plot using a custom container and :class:`.wrappers.PathCollectionWrapper`
89
910"""
1011import time
1920
2021from data_prototype .containers import _MatplotlibTransform , Desc
2122
22- from data_prototype .wrappers import PathCollectionWrapper , FormatedText
23+ from data_prototype .wrappers import PathCollectionWrapper
2324
2425
2526class Lissajous :
@@ -31,7 +32,6 @@ def describe(self):
3132 return {
3233 "x" : Desc ([self .N ], float ),
3334 "y" : Desc ([self .N ], float ),
34- "phase" : Desc ([], float ),
3535 "time" : Desc ([], float ),
3636 "sizes" : Desc ([], float ),
3737 "paths" : Desc ([], float ),
@@ -53,7 +53,6 @@ def next_time():
5353 return {
5454 "x" : np .cos (5 * phase ),
5555 "y" : np .sin (3 * phase ),
56- "phase" : phase [0 ],
5756 "sizes" : np .array ([256 ]),
5857 "paths" : [marker_obj .get_path ().transformed (marker_obj .get_transform ())],
5958 "edgecolors" : "k" ,
@@ -70,27 +69,19 @@ def update(frame, art):
7069
7170sot_c = Lissajous ()
7271
73- fc = FormatedText (
74- sot_c ,
75- {"text" : lambda phase : f"ϕ={ phase :.2f} " },
76- x = 1 ,
77- y = 1 ,
78- ha = "right" ,
79- )
8072fig , ax = plt .subplots ()
8173ax .set_xlim (- 1.1 , 1.1 )
8274ax .set_ylim (- 1.1 , 1.1 )
8375lw = PathCollectionWrapper (sot_c , offset_transform = ax .transData )
8476ax .add_artist (lw )
85- ax .add_artist (fc )
8677# ax.set_xticks([])
8778# ax.set_yticks([])
8879ax .set_aspect (1 )
8980ani = FuncAnimation (
9081 fig ,
91- partial (update , art = (lw , fc )),
92- frames = 60 * 15 ,
93- interval = 1000 / 100 ,
82+ partial (update , art = (lw ,)),
83+ frames = 60 ,
84+ interval = 1000 / 100 * 15 ,
9485 # TODO: blitting does not work because wrappers do not inherent from Artist
9586 # blit=True,
9687)
0 commit comments