-
Notifications
You must be signed in to change notification settings - Fork 2
/
Plot.py
44 lines (32 loc) · 1.07 KB
/
Plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import matplotlib.pyplot as plt
import numpy
class Plotter:
def __init__(self, xlabel='X', ylabel='Y', title='Tower Performances', lineType='ro'):
self.xlabel = xlabel
self.ylabel = ylabel
self.title = title
self.lineType = lineType
self.fig = plt.figure()
self.ax = plt.subplot(1,1,1)
self.xdata = []
self.ydata = []
def show(self):
plt.ion()
self.ax.set_xlabel(self.xlabel)
self.ax.set_ylabel(self.ylabel)
plt.title(self.title)
self.ax.plot(self.xdata, self.ydata, self.lineType, markersize=6)
plt.grid(True)
plt.show(block=False)
def save(self, loc):
plt.savefig(loc)
def updatePlot(self):
self.ax.lines[0].set_data(self.xdata,self.ydata)
self.ax.relim()
self.ax.autoscale_view()
plt.xticks(numpy.arange(min(self.xdata), max(self.xdata)+1, 1.0))
self.fig.canvas.flush_events()
def addxData(self,x):
self.xdata.append(x)
def addyData(self,y):
self.ydata.append(y)