-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot.py
49 lines (42 loc) · 1.63 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
45
46
47
48
49
# ----------------------------------------------- 定义一个画图类
import matplotlib.pyplot as plt
class Draw:
__i = 5
def __init__(self):
self.X_re = []
self.Y_re = []
self.X_bar = []
self.Y_bar = []
def draw(self,X,Y,X_bar, Y_bar):
plt.clf() # 清空画布上的所有内容
self.X_re.append(X) # 模拟数据增量流入,保存历史数据
self.Y_re.append(Y) # 模拟数据增量流入,保存历史数据
self.X_bar.append(X_bar)
self.Y_bar.append(Y_bar)
plt.plot(self.X_re, self.Y_re, '.b')
plt.plot(self.X_bar, self.Y_bar, '.r')
plt.plot
plt.show()
# def draw2(self, X_bar, Y_bar):
# # plt.clf() # 清空画布上的所有内容
# self.X_re.append(X_bar) # 模拟数据增量流入,保存历史数据
# self.Y_re.append(Y_bar) # 模拟数据增量流入,保存历史数据
# plt.plot(self.X_re, self.Y_re, '.r')
# plt.show()
# ---------------------------------------------------------------- 待处理
# class Draw:
#
# def draw(self,X,Y,X_bar, Y_bar):
#
# plt.plot(X,Y,'.b')
# plt.plot(X_bar,Y_bar,'.r')
# plt.show()
# ---------------------------------------------------------------- 待处理
# global __i
# __i = __i - 1
#
# if __i == 1: # 每5个新点画一幅图
# __i = 5
# plt.plot(self.X_re, self.Y_re, '.b')
# plt.show()
# # plt.pause(0.01)