Plot.py 540 B

123456789101112131415161718192021222324
  1. import matplotlib
  2. from matplotlib.figure import Figure
  3. from matplotlib import style
  4. class Plot():
  5. def __init__(self, n):
  6. self.fig = Figure()
  7. self.ax = self.fig.add_subplot(111)
  8. self.xs = range(n)
  9. self.ys = [0] * n
  10. self.i = 0
  11. self.n = n
  12. def update(self, y):
  13. # Add x and y to lists
  14. ys[i] = y
  15. i = i+1 if i+1 < self.n else 0
  16. ax.clear()
  17. ax.plot(xs, ys, "#00A3E0", label="1. Graph")
  18. ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
  19. ax.set_title('Windkanal')