Plot.py 818 B

1234567891011121314151617181920212223242526272829303132
  1. import matplotlib
  2. from matplotlib.figure import Figure
  3. from matplotlib import style
  4. import numpy as np
  5. from .globals import *
  6. style.use("ggplot")
  7. class Plot():
  8. def __init__(self, points, plots = 1):
  9. self.fig = Figure()
  10. self.ax = self.fig.add_subplot(111)
  11. self.xs = range(points)
  12. self.ys = np.ndarray(shape=(plots, points), dtype=float)
  13. self.i = 0
  14. self.points = points
  15. self.plots = plots
  16. def setTitle(self, title):
  17. self.ax.set_title('Windkanal')
  18. def update(self, values):
  19. self.ax.clear()
  20. for p in range(self.plots):
  21. self.ys[p][self.i] = values[p]
  22. self.ax.plot(self.xs, self.ys[p], "#00A3E0", label=f"{p+1}. Graph")
  23. self.i = (self.i+1) % self.points
  24. self.ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)