-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempgraph.py
More file actions
185 lines (157 loc) · 7.18 KB
/
tempgraph.py
File metadata and controls
185 lines (157 loc) · 7.18 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import flet as ft
from flet.matplotlib_chart import MatplotlibChart
import japanize_matplotlib
matplotlib.use("svg")
class tempGraph(ft.UserControl):
def __init__(self, visible=True):
super().__init__(self)
#追加したプロパティ
self.counter = 0
self.on_countup = lambda: None
self.visibleBool = visible
self.fig, self.axs = plt.subplots(2, 2, figsize=(8, 8)) # (1)fig, axs = plt.subplots(2, 2)で2x2のグラフを作成
self.fig.subplots_adjust(wspace=0.3, hspace=0.3, top=0.95, bottom=0.07, right=0.98, left=0.13) # (2)グラフ間のスペースを設定
# 折れ線グラフを出力
self.x0 = np.array([])
self.y01 = np.array([])
self.y02 = np.array([])
self.y03 = np.array([])
self.y04 = np.array([])
self.y05 = np.array([])
self.axs[0, 0].plot(self.x0, self.y01, color="k", label="temp")
self.axs[0, 0].plot(self.x0, self.y02, color="b", label="a0")
self.axs[0, 0].plot(self.x0, self.y03, color="r", label="a1")
self.axs[0, 0].plot(self.x0, self.y04, color="g", label="a2")
self.axs[0, 0].plot(self.x0, self.y05, color="m", label="a3")
self.axs[0, 0].set_xlabel("time")
self.axs[0, 0].set_ylabel("temp[℃]")
self.axs[0, 0].grid(True)
self.axs[0, 0].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[0, 0].set_title("Outside temperature and inside temperature")
self.axs[0, 0].ylim = (0, 100)
self.y06 = np.array([])
self.y07 = np.array([])
self.y08 = np.array([])
self.axs[0, 1].plot(self.x0, self.y08)
self.axs[0, 1].set_xlabel("time")
self.axs[0, 1].set_ylabel("Altitude[m]")
self.axs[0, 1].grid(True)
self.axs[0, 1].set_title("Altitude")
# self.axs[0, 1].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[1, 0].plot(self.x0, self.y06)
self.axs[1, 0].set_xlabel("time")
self.axs[1, 0].set_ylabel("Pressure[hPa]")
self.axs[1, 0].grid(True)
self.axs[1, 0].set_title("Pressure")
# self.axs[1, 0].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[1, 1].plot(self.x0, self.y07)
self.axs[1, 1].set_xlabel("time")
self.axs[1, 1].set_ylabel("Humidity[%]")
self.axs[1, 1].grid(True)
self.axs[1, 1].set_title("Humidity")
# self.axs[1, 1].legend(loc="lower left", fontsize=8) # (3)凡例表示
async def setVisible(self, visibleb):
self.visibleBool = visibleb
await self.update_async()
async def setVisibleYes(self):
self.visibleBool = True
self.visible = True
await self.update_async()
async def setVisibleNot(self):
self.visibleBool = False
self.visible = False
await self.update_async()
async def set(self, time, temp, pressure, humidity, altitude, a0, a1, a2, a3):
self.axs[0, 0].cla()
self.axs[0, 1].cla()
self.axs[1, 0].cla()
self.axs[1, 1].cla()
self.x0 = np.array(time)
self.y01 = np.array(temp)
self.y02 = np.array(a0)
self.y03 = np.array(a1)
self.y04 = np.array(a2)
self.y05 = np.array(a3)
self.axs[0, 0].ylim = (0, 100)
self.axs[0, 0].plot(self.x0, self.y01, color="k", label="temp")
self.axs[0, 0].plot(self.x0, self.y02, color="b", label="a0")
self.axs[0, 0].plot(self.x0, self.y03, color="r", label="a1")
self.axs[0, 0].plot(self.x0, self.y04, color="g", label="a2")
self.axs[0, 0].plot(self.x0, self.y05, color="m", label="a3")
self.axs[0, 0].set_xlabel("time")
self.axs[0, 0].set_ylabel("temp[℃]")
self.axs[0, 0].grid(True)
self.axs[0, 0].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[0, 0].set_title("Outside temperature and inside temperature")
self.y06 = np.array(pressure)
self.y07 = np.array(humidity)
self.y08 = np.array(altitude)
self.axs[0, 1].plot(self.x0, self.y08)
self.axs[0, 1].set_xlabel("time")
self.axs[0, 1].set_ylabel("Altitude[m]")
self.axs[0, 1].grid(True)
self.axs[0, 1].set_title("Altitude")
# self.axs[0, 1].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[1, 0].plot(self.x0, self.y06)
self.axs[1, 0].set_xlabel("time")
self.axs[1, 0].set_ylabel("Pressure[hPa]")
self.axs[1, 0].grid(True)
self.axs[1, 0].set_title("Pressure")
# self.axs[1, 0].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[1, 1].plot(self.x0, self.y07)
self.axs[1, 1].set_xlabel("time")
self.axs[1, 1].set_ylabel("Humidity[%]")
self.axs[1, 1].grid(True)
self.axs[1, 1].set_title("Humidity")
# self.axs[1, 1].legend(loc="lower left", fontsize=8) # (3)凡例表示
await self.update_async()
async def reset(self):
self.axs[0, 0].cla()
self.axs[0, 1].cla()
self.axs[1, 0].cla()
self.axs[1, 1].cla()
# self.fig, self.axs = plt.subplots()
self.x0 = np.array([])
self.y01 = np.array([])
self.y02 = np.array([])
self.y03 = np.array([])
self.y04 = np.array([])
self.y05 = np.array([])
self.axs[0, 0].plot(self.x0, self.y01, color="k", label="temp")
self.axs[0, 0].plot(self.x0, self.y02, color="b", label="a0")
self.axs[0, 0].plot(self.x0, self.y03, color="r", label="a1")
self.axs[0, 0].plot(self.x0, self.y04, color="g", label="a2")
self.axs[0, 0].plot(self.x0, self.y05, color="m", label="a3")
self.axs[0, 0].set_xlabel("time")
self.axs[0, 0].set_ylabel("temp[℃]")
self.axs[0, 0].grid(True)
self.axs[0, 0].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[0, 0].set_title("Outside temperature and inside temperature")
self.axs[0, 0].ylim = (0, 100)
self.y06 = np.array([])
self.y07 = np.array([])
self.y08 = np.array([])
self.axs[0, 1].plot(self.x0, self.y08)
self.axs[0, 1].set_xlabel("time")
self.axs[0, 1].set_ylabel("Altitude[m]")
self.axs[0, 1].grid(True)
self.axs[0, 1].set_title("Altitude")
# self.axs[0, 1].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[1, 0].plot(self.x0, self.y06)
self.axs[1, 0].set_xlabel("time")
self.axs[1, 0].set_ylabel("Pressure[hPa]")
self.axs[1, 0].grid(True)
self.axs[1, 0].set_title("Pressure")
# self.axs[1, 0].legend(loc="lower left", fontsize=8) # (3)凡例表示
self.axs[1, 1].plot(self.x0, self.y07)
self.axs[1, 1].set_xlabel("time")
self.axs[1, 1].set_ylabel("Humidity[%]")
self.axs[1, 1].grid(True)
self.axs[1, 1].set_title("Humidity")
# self.axs[1, 1].legend(loc="lower left", fontsize=8) # (3)凡例表示
await self.update_async()
def build(self):
return MatplotlibChart(self.fig, expand=True, visible=self.visibleBool)