|
@@ -1,7 +1,7 @@
|
|
import matplotlib
|
|
import matplotlib
|
|
from matplotlib.figure import Figure
|
|
from matplotlib.figure import Figure
|
|
from matplotlib import style
|
|
from matplotlib import style
|
|
-
|
|
|
|
|
|
+import numpy as np
|
|
|
|
|
|
from .globals import *
|
|
from .globals import *
|
|
|
|
|
|
@@ -9,21 +9,24 @@ style.use("ggplot")
|
|
|
|
|
|
|
|
|
|
class Plot():
|
|
class Plot():
|
|
- def __init__(self, n):
|
|
|
|
|
|
+ def __init__(self, points, plots = 1):
|
|
self.fig = Figure()
|
|
self.fig = Figure()
|
|
self.ax = self.fig.add_subplot(111)
|
|
self.ax = self.fig.add_subplot(111)
|
|
- self.xs = range(n)
|
|
|
|
- self.ys = [0] * n
|
|
|
|
|
|
+ self.xs = range(points)
|
|
|
|
+ self.ys = np.ndarray(shape=(plots, points), dtype=float)
|
|
self.i = 0
|
|
self.i = 0
|
|
- self.n = n
|
|
|
|
-
|
|
|
|
- def update(self, y):
|
|
|
|
- # Add x and y to lists
|
|
|
|
- ys[i] = y
|
|
|
|
- i = i+1 if i+1 < self.n else 0
|
|
|
|
|
|
+ self.points = points
|
|
|
|
+ self.plots = plots
|
|
|
|
|
|
|
|
+ def setTitle(self, title):
|
|
|
|
+ self.ax.set_title('Windkanal')
|
|
|
|
|
|
- ax.clear()
|
|
|
|
- ax.plot(xs, ys, "#00A3E0", label="1. Graph")
|
|
|
|
- ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
|
|
|
|
- ax.set_title('Windkanal')
|
|
|
|
|
|
+ def update(self, values):
|
|
|
|
+ self.ax.clear()
|
|
|
|
+ for p in range(self.plots):
|
|
|
|
+ self.ys[p][self.i] = values[p]
|
|
|
|
+ self.ax.plot(self.xs, self.ys[p], "#00A3E0", label=f"{p+1}. Graph")
|
|
|
|
+
|
|
|
|
+ self.i = (self.i+1) % self.points
|
|
|
|
+ self.ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
|
|
|
|
+
|