質問編集履歴

1

どうしてもかきたきいから

2021/06/06 18:54

投稿

Winter_1214
Winter_1214

スコア11

test CHANGED
File without changes
test CHANGED
@@ -207,3 +207,89 @@
207
207
  [tkinterのウインド上にグラフを表示する](https://www.stjun.com/entry/2020/01/11/185323)
208
208
 
209
209
  [youtubeapi](https://developers.google.com/youtube/v3/docs/videos?hl=ja)
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ ###追加ソース
222
+
223
+ ```python
224
+
225
+ dataX = [nowma,nowmae,nowmae]
226
+
227
+ dataY = ['0','2','2']
228
+
229
+ def main():
230
+
231
+ global dataY
232
+
233
+ fig = plt.figure()
234
+
235
+ plt.title("グラフ",fontname="MS Gothic")
236
+
237
+ plt.xlabel("時間", fontname="MS Gothic")
238
+
239
+ plt.ylabel("視聴中数", fontname="MS Gothic")
240
+
241
+ dataY = sorted(dataY)
242
+
243
+ plt.tight_layout()
244
+
245
+
246
+
247
+ plt.plot(dataX, dataY);
248
+
249
+ fig.savefig("img.png")
250
+
251
+ canvas = FigureCanvasTkAgg(fig, master=root)
252
+
253
+
254
+
255
+ canvas = FigureCanvasTkAgg(fig, master=root)
256
+
257
+ canvas.draw()
258
+
259
+ toolbar = NavigationToolbar2Tk(canvas, root)
260
+
261
+ toolbar.update()
262
+
263
+ canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
264
+
265
+
266
+
267
+ canvas.flush_events()
268
+
269
+ root.after_idle(5000, get_data)
270
+
271
+
272
+
273
+ def get_data():
274
+
275
+ time.sleep(5)
276
+
277
+ for channel in videos:
278
+
279
+ print(channel)
280
+
281
+ dataX.append(now)
282
+
283
+ dataY.append(str(channel[1]))
284
+
285
+ root.after_idle(5000, get_data)
286
+
287
+
288
+
289
+
290
+
291
+ main()
292
+
293
+ root.mainloop()
294
+
295
+ ```