Python pyqtgraph.setConfigOptions() Examples

The following are 12 code examples of pyqtgraph.setConfigOptions(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pyqtgraph , or try the search function .
Example #1
Source File: test_ROI.py    From tf-pose with Apache License 2.0 7 votes vote down vote up
def test_getArrayRegion(transpose=False):
    pr = pg.PolyLineROI([[0, 0], [27, 0], [0, 28]], closed=True)
    pr.setPos(1, 1)
    rois = [
        (pg.ROI([1, 1], [27, 28], pen='y'), 'baseroi'),
        (pg.RectROI([1, 1], [27, 28], pen='y'), 'rectroi'),
        (pg.EllipseROI([1, 1], [27, 28], pen='y'), 'ellipseroi'),
        (pr, 'polylineroi'),
    ]
    for roi, name in rois:
        # For some ROIs, resize should not be used.
        testResize = not isinstance(roi, pg.PolyLineROI)
        
        origMode = pg.getConfigOption('imageAxisOrder')
        try:
            if transpose:
                pg.setConfigOptions(imageAxisOrder='row-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize, transpose=True)
            else:
                pg.setConfigOptions(imageAxisOrder='col-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize)
        finally:
            pg.setConfigOptions(imageAxisOrder=origMode) 
Example #2
Source File: play.py    From simulator with GNU General Public License v3.0 7 votes vote down vote up
def plot_team(self):
        # these would contain list of x coordinates
        self.Monitors_rounds = []
        self.WIPs_rounds = []
        self.MPs_rounds = []
        # these would contain list of yc coordinates
        self.Monitors_qty = []
        self.WIPs_qty = []
        self.MPs_qty = []
        self.win = pg.GraphicsLayoutWidget()
        self.win.setWindowTitle("Number of Peers in the Team")
        self.win.resize(800, 600)

        # Enable antialiasing for prettier plots
        # pg.setConfigOptions(antialias=True)
        self.p3 = self.win.addPlot()    # Adding plot to window like matplotlib subplot method
        self.p3.addLegend()
        # Create separate plots to handle regular,monitor and malicious peer it is much like matplotlib plot method
        self.lineWIPs = self.p3.plot(pen=(None), symbolBrush=(0, 0, 255), symbolPen='b', name='#WIP')
        self.lineMonitors = self.p3.plot(pen=(None), symbolBrush=(0, 255, 0), symbolPen='g', name='#Monitors Peers')
        self.lineMPs = self.p3.plot(pen=(None), symbolBrush=(255, 0, 0), symbolPen='r', name='Malicious Peers')

        total_peers = self.number_of_monitors + self.number_of_peers + self.number_of_malicious
        self.p3.setRange(xRange=[0, self.number_of_rounds], yRange=[0, total_peers])
        self.win.show() 
Example #3
Source File: test_ROI.py    From soapy with GNU General Public License v3.0 6 votes vote down vote up
def test_getArrayRegion(transpose=False):
    pr = pg.PolyLineROI([[0, 0], [27, 0], [0, 28]], closed=True)
    pr.setPos(1, 1)
    rois = [
        (pg.ROI([1, 1], [27, 28], pen='y'), 'baseroi'),
        (pg.RectROI([1, 1], [27, 28], pen='y'), 'rectroi'),
        (pg.EllipseROI([1, 1], [27, 28], pen='y'), 'ellipseroi'),
        (pr, 'polylineroi'),
    ]
    for roi, name in rois:
        # For some ROIs, resize should not be used.
        testResize = not isinstance(roi, pg.PolyLineROI)
        
        origMode = pg.getConfigOption('imageAxisOrder')
        try:
            if transpose:
                pg.setConfigOptions(imageAxisOrder='row-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize, transpose=True)
            else:
                pg.setConfigOptions(imageAxisOrder='col-major')
                check_getArrayRegion(roi, 'roi/'+name, testResize)
        finally:
            pg.setConfigOptions(imageAxisOrder=origMode) 
Example #4
Source File: test_ImageItem.py    From tf-pose with Apache License 2.0 5 votes vote down vote up
def test_ImageItem_axisorder():
    # All image tests pass again using the opposite axis order
    origMode = pg.getConfigOption('imageAxisOrder')
    altMode = 'row-major' if origMode == 'col-major' else 'col-major'
    pg.setConfigOptions(imageAxisOrder=altMode)
    try:
        test_ImageItem(transpose=True)
    finally:
        pg.setConfigOptions(imageAxisOrder=origMode) 
Example #5
Source File: twiss_plot.py    From ocelot with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self):
        
        pg.setConfigOptions(antialias=True)
        self.twiss_plot = pg.GraphicsLayoutWidget()

        # Switch to using white background and black foreground
        #pg.setConfigOption('background', 'w')
        #pg.setConfigOption('foreground', 'k')

        self.plot_disp_x = self.twiss_plot.addPlot(row=0, col=0)
        self.plot_disp_x.showGrid(x=True, y=True)

        self.plot_beta = self.twiss_plot.addPlot(row=1, col=0)
        self.plot_beta.showGrid(x=True, y=True)

        self.plot_lattice = self.twiss_plot.addPlot(row=3, col=0)
        self.plot_lattice.showGrid(x=False, y=False)
        #self.plot_lattice.hideAxis('left')
        self.plot_lattice.setMenuEnabled(enableMenu=False)

        self.plot_disp_x.setXLink(self.plot_lattice)
        self.plot_disp_x.addLegend()
        self.plot_beta.setXLink(self.plot_lattice)
        self.plot_beta.addLegend()

        color_blue = QtGui.QColor(0, 0, 255)
        color_red = QtGui.QColor(255, 0, 0)
        color_aqua = QtGui.QColor(0, 255, 255)
        
        pen_blue = pg.mkPen(color_blue, width=2)
        pen_red = pg.mkPen(color_red, width=2)
        pen_aqua = pg.mkPen(color_aqua, width=2)

        self.curv1 = self.plot_disp_x.plot(pen=pen_aqua, name='Dx')
        self.curv2 = self.plot_beta.plot(pen=pen_aqua, name='betaX')
        self.curv3 = self.plot_beta.plot(pen=pen_red, name='betaY') 
Example #6
Source File: play.py    From simulator with GNU General Public License v3.0 5 votes vote down vote up
def draw_net(self):
        pg.setConfigOptions(antialias=True)
        self.w = pg.GraphicsWindow()    # Create new window like matplotlib pyplot
        self.w.resize(800, 600)
        self.w.setWindowTitle('Overlay Network of the Team')
        self.v = self.w.addViewBox()  # Add ViewBox that would contain all the graphics i.e graph structure
        self.v.setAspectLocked()
        self.G = Graph()  # Child class of pg.GraphItem that would contain all the nodes and edges
        self.v.addItem(self.G)
        self.color_map = {'peer': (169, 188, 245, 255), 'monitor': (
            169, 245, 208, 255), 'malicious': (247, 129, 129, 255)} 
Example #7
Source File: plotter.py    From digikala_history with MIT License 5 votes vote down vote up
def __init__(self, parent=None, **kargs):
        pg.GraphicsWindow.__init__(self, **kargs)
        self.setParent(parent)
        self.setWindowTitle('')
        # Enable antialiasing for prettier plots
        pg.setConfigOptions(antialias=True)
        self.p6 = self.addPlot(title="")
        self.curve = self.p6.plot(pen='r') 
Example #8
Source File: __init__.py    From argos with GNU General Public License v3.0 5 votes vote down vote up
def setPgConfigOptions(**kwargs):
    """ Sets the PyQtGraph config options and emits a log message
    """
    for key, value in kwargs.items():
        logger.debug("Setting PyQtGraph config option: {} = {}".format(key, value))

    pg.setConfigOptions(**kwargs)


# Sets some config options 
Example #9
Source File: diffshow.py    From scikit-ued with MIT License 5 votes vote down vote up
def rowmajor_axisorder():
    """
    Context manager that sets the PyQtGraph image axis order to row-major. 
    The environment is reset to the initial value after context close.
    """
    old_image_axis_order = pg.getConfigOption("imageAxisOrder")
    pg.setConfigOptions(imageAxisOrder="row-major")
    yield
    pg.setConfigOptions(imageAxisOrder=old_image_axis_order) 
Example #10
Source File: __init__.py    From finplot with MIT License 5 votes vote down vote up
def create_plot(title='Finance Plot', rows=1, init_zoom_periods=1e10, maximize=True, yscale='linear'):
    global windows, last_ax
    pg.setConfigOptions(foreground=foreground, background=background)
    win = FinWindow(title)
    windows.append(win)
    if maximize:
        win.showMaximized()
    # normally first graph is of higher significance, so enlarge
    win.ci.layout.setRowStretchFactor(0, top_graph_scale)
    win.ci.setContentsMargins(0, 0, 0 ,0)
    win.ci.setSpacing(0)
    axs = []
    prev_ax = None
    for n in range(rows):
        ysc = yscale[n] if type(yscale) in (list,tuple) else yscale
        ysc = YScale(ysc, 1)
        v_zoom_scale = 0.97
        viewbox = FinViewBox(win, init_steps=init_zoom_periods, yscale=ysc, v_zoom_scale=v_zoom_scale)
        ax = prev_ax = _add_timestamp_plot(win, prev_ax, viewbox=viewbox, index=n, yscale=ysc)
        _set_plot_x_axis_leader(ax)
        if n == 0:
            viewbox.setFocus()
        axs += [ax]
    win.proxy_mmove = pg.SignalProxy(win.scene().sigMouseMoved, rateLimit=144, slot=partial(_mouse_moved, win))
    win._last_mouse_evs = None
    win._last_mouse_y = 0
    last_ax = axs[0]
    if len(axs) == 1:
        return axs[0]
    return axs 
Example #11
Source File: test_ImageItem.py    From soapy with GNU General Public License v3.0 5 votes vote down vote up
def test_ImageItem_axisorder():
    # All image tests pass again using the opposite axis order
    origMode = pg.getConfigOption('imageAxisOrder')
    altMode = 'row-major' if origMode == 'col-major' else 'col-major'
    pg.setConfigOptions(imageAxisOrder=altMode)
    try:
        test_ImageItem(transpose=True)
    finally:
        pg.setConfigOptions(imageAxisOrder=origMode) 
Example #12
Source File: usrp_demo.py    From pysdr with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self):
        super().__init__()
        
        # Set up layout
        grid = QGridLayout()
        self.setLayout(grid)
        
        pg.setConfigOptions(antialias=False) # True seems to work as well

        # Create pushbutton that resets the views
        self.button = QPushButton('Reset All Zooms', self)
        self.button.clicked.connect(self.handleButton)
        grid.addWidget(self.button, 0, 0)
        
        
        # create time plot
        self.time_plot = pg.PlotWidget(labels={'left': 'Amplitude', 'bottom': 'Time [microseconds]'}, enableMenu=False)
        self.time_plot.getPlotItem().getViewBox().setMouseMode(pg.ViewBox.RectMode)
        self.time_plot.setMouseEnabled(x=False, y=True)
        self.time_plot_curve_i = self.time_plot.plot([]) 
        self.time_plot_curve_q = self.time_plot.plot([]) 
        grid.addWidget(self.time_plot, 1, 0)
        
        # create fft plot
        self.fft_plot = pg.PlotWidget(labels={'left': 'PSD', 'bottom': 'Frequency [MHz]'}, enableMenu=False)
        self.fft_plot.getPlotItem().getViewBox().setMouseMode(pg.ViewBox.RectMode)
        self.fft_plot.setMouseEnabled(x=False, y=True)
        self.fft_plot_curve_fft = self.fft_plot.plot([]) 
        grid.addWidget(self.fft_plot, 2, 0)
        
        # Create waterfall plot
        self.waterfall = pg.PlotWidget(labels={'left': 'Time [s]', 'bottom': 'Frequency [MHz]'}, enableMenu=False)
        self.waterfall.getPlotItem().getViewBox().translateBy(x=10.0)
        self.imageitem = pg.ImageItem()
        self.waterfall.addItem(self.imageitem)
        self.waterfall.setMouseEnabled(x=False, y=False)
        grid.addWidget(self.waterfall, 3, 0)
  
        self.setGeometry(300, 300, 300, 220) # window placement and size
        self.setWindowTitle('RTL-SDR Demo')
    
        self.show() # not blocking