我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用pyqtgraph.mkQApp()。
def __init__(self, video, result): self.video = video self.result = result app = pg.mkQApp() self.win = pg.GraphicsWindow(title="Live webcam") self.win.resize(640,480) box = self.win.addViewBox(lockAspect=True) box.invertY() self.vis = pg.ImageItem() box.addItem(self.vis) box = self.win.addViewBox(lockAspect=True) box.invertY() self.res = pg.ImageItem() box.addItem(self.res) self.win.show() self.lastUpdate = pg.ptime.time() self.avgFps = 0.0
def plot_data(data, scroll_axis=2): """ Plot an image associated data. Currently support on 1D, 2D or 3D data. Parameters ---------- data: array the data to be displayed. scroll_axis: int (optional, default 2) the scroll axis for 3d data. """ # Check input parameters if data.ndim not in range(1, 4): raise ValueError("Unsupported data dimension.") # Deal with complex data if numpy.iscomplex(data).any(): data = numpy.abs(data) # Create application app = pyqtgraph.mkQApp() # Create the widget if data.ndim == 3: indices = [i for i in range(3) if i != scroll_axis] indices = [scroll_axis] + indices widget = pyqtgraph.image(numpy.transpose(data, indices)) elif data.ndim == 2: widget = pyqtgraph.image(data) else: widget = pyqtgraph.plot(data) # Run application app.exec_()
def __init__(self, func): self.func = func app = pg.mkQApp() self.win = pg.GraphicsWindow(title="Bar learning") self.win.resize(800,800) self.win.addLabel("Input") self.win.addLabel("Feature") self.win.nextRow() box = self.win.addViewBox(lockAspect=True) self.input_vis = pg.ImageItem() box.addItem(self.input_vis) box = self.win.addViewBox(lockAspect=True) self.feature_vis = pg.ImageItem() box.addItem(self.feature_vis) self.win.nextRow() self.win.addLabel("Receptive fields", colspan=2) self.win.nextRow() box = self.win.addViewBox(lockAspect=True, colspan=2) self.rv_vis = pg.ImageItem() box.addItem(self.rv_vis) self.win.show()
def __init__(self, points, title = None): pg.mkQApp(); self.w = gl.GLViewWidget() self.w.opts['distance'] = 20 self.w.show() self.w.setWindowTitle(title) self.g = gl.GLGridItem() self.w.addItem(self.g) self.sp = gl.GLScatterPlotItem(pos=points, color=(1,1,1,1), pxMode= True) self.w.addItem(self.sp); #self.plot.addItem(self.w); # ### create three grids, add each to the view #xgrid = gl.GLGridItem() #ygrid = gl.GLGridItem() #zgrid = gl.GLGridItem() #view.addItem(xgrid) #view.addItem(ygrid) #view.addItem(zgrid) # ### rotate x and y grids to face the correct direction #xgrid.rotate(90, 0, 1, 0) #ygrid.rotate(90, 1, 0, 0) # ### scale each grid differently #xgrid.scale(0.2, 0.1, 0.1) #ygrid.scale(0.2, 0.1, 0.1) #zgrid.scale(0.1, 0.2, 0.1)