forked from sllurp/sllurp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdraw_pyqt.py
More file actions
47 lines (39 loc) · 1.42 KB
/
Copy pathdraw_pyqt.py
File metadata and controls
47 lines (39 loc) · 1.42 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
'''
빠른 전환을 위해 matplotlib + seaborn에서 pyqtgraph로 그리도록 바꿈
'''
from PyQt5 import QtWidgets, QtCore
from pyqtgraph import PlotWidget, plot
import numpy as np
import pyqtgraph as pg
import sys # We need sys so that we can pass argv to QApplication
import os
from random import randint
class MainWindow(QtWidgets.QMainWindow):
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.window= pg.GraphicsLayoutWidget(title='mk')
self.image = pg.ImageItem()
self.view_box = pg.ViewBox()
self.window.rotate(180)
self.setCentralWidget(self.window)
self.resize(1000,1000)
self.data = np.random.normal(size=(20,20))
self.image.setImage(self.data)
self.view_box.setLimits(xMin=0,xMax=8, yMin=0, yMax=8)
self.view_box.addItem(self.image)
self.view_box.disableAutoRange()
self.view_box.invertY()
self.plot = pg.PlotItem(viewBox=self.view_box)
self.window.addItem(self.plot)
self.timer = QtCore.QTimer()
self.timer.setInterval(100)
self.timer.timeout.connect(self.update_plot_data)
self.timer.start()
def update_plot_data(self):
data2 = np.random.normal(size=(8, 8))
self.image.setImage(data2)
self.view_box.addItem(self.image)
app = QtWidgets.QApplication(sys.argv)
w = MainWindow()
w.show()
sys.exit(app.exec_())