-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMatplotlibAnimator.py
44 lines (33 loc) · 1.12 KB
/
MatplotlibAnimator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import matplotlib.pyplot as plt
class MatplotlibAnimator:
"""
The animator instance driven by Matplotlib.
"""
def __init__(self, simulationData, domainSize):
"""
Constructor.
keyword arguments:
simulationData -- The simulation data array.
domainSize -- The tuple that represents the lenghts of the square domain in each dimension.
"""
self._simulationData = simulationData
self._domainSize = domainSize
self._initialize()
def prepare(self, animator):
"""
Prepares the appropriate animator.
keyword arguments:
animator -- The appropriate animator class.
return:
Prepared animator feeded with simulation data.
"""
preparedAnimator = animator.prepareAnimation(self._figure)
return preparedAnimator.feedSimulationData(self._simulationData, self._domainSize)
def _initialize(self):
"""
Initializes matplotlib for animation.
return:
plt.figure()
"""
self._figure = plt.figure()
return self._figure