Plot.py 593 B

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