|
@@ -9,25 +9,32 @@ style.use("ggplot")
|
|
|
|
|
|
|
|
|
class Plot():
|
|
|
- def __init__(self, points, plots = 1):
|
|
|
+ def __init__(self, points, lines = 1):
|
|
|
matplotlib.use('TkAgg')
|
|
|
self.fig = Figure()
|
|
|
self.ax = self.fig.add_subplot(111)
|
|
|
self.xs = range(points)
|
|
|
- self.ys = np.ndarray(shape=(plots, points), dtype=float)
|
|
|
+ self.ys = np.ndarray(shape=(lines, points), dtype=float)
|
|
|
self.i = 0
|
|
|
self.points = points
|
|
|
- self.plots = plots
|
|
|
+ self.plots = [None] * lines
|
|
|
+ for p in range(lines):
|
|
|
+ self.plots[p], = self.ax.plot(self.xs, self.ys[p], "#00A3E0", label="{}. Graph".format(p+1))
|
|
|
+
|
|
|
+ self.ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
|
|
|
|
|
|
def setTitle(self, title):
|
|
|
- self.ax.set_title('Windkanal')
|
|
|
+ self.ax.set_title(title)
|
|
|
|
|
|
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="{}. Graph".format(p+1))
|
|
|
+
|
|
|
+ self.ax.draw_artist(self.ax.patch)
|
|
|
+ for p in range(len(self.plots)):
|
|
|
+ self.ys[p] = np.append([values[p]], self.ys[p][:-1])
|
|
|
+ self.plots[p].set_ydata(self.ys[p])
|
|
|
+ self.ax.draw_artist(self.plots[p])
|
|
|
|
|
|
+ self.fig.canvas.draw()
|
|
|
+
|
|
|
self.i = (self.i+1) % self.points
|
|
|
- self.ax.legend(bbox_to_anchor=(0, 1.02, 1, .102), loc=3, ncol=2, borderaxespad=0)
|
|
|
|