This commit is contained in:
2021-05-08 13:55:56 +02:00
parent 97a34ca997
commit 2492edda48
7 changed files with 256 additions and 172 deletions

31
animation.py Normal file
View File

@ -0,0 +1,31 @@
from matplotlib import pyplot as plt
# expect from source:
# - get() -> value
# - name
# - add_callback(cb)
# - disconnect()
# plot_func takes result of source.get()
# returns Plot object
# Plot object has set(val)
class Animation:
def __init__(self, source, plot_func):
value = source.get()
self.plot = plot_func(value)
plt.suptitle(source.name)
source.add_callback(self.update)
plt.show()
source.disconnect()
def update(self, value=None, **kwargs):
self.plot.set(value)
plt.draw()