def __init__(self):
        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Plot with synchronized axes")
        widget = qt.QWidget(self)
        self.setCentralWidget(widget)

        layout = qt.QGridLayout()
        widget.setLayout(layout)

        backend = "mpl"

        data = numpy.arange(100 * 100)
        data = (data % 100) / 5.0
        data = numpy.sin(data)
        data = silx.test.utils.add_gaussian_noise(data, mean=0.01)
        data.shape = 100, 100

        data1d = numpy.mean(data, axis=0)

        self.plot2d = plot.Plot2D(parent=widget, backend=backend)
        self.plot2d.setGraphTitle("A pixel can't be too big")
        self.plot2d.setInteractiveMode('pan')
        self.plot2d.addImage(data)
        self.plot2d.getXAxis().setRangeConstraints(minRange=10)
        self.plot2d.getYAxis().setRangeConstraints(minRange=10)

        self.plot2d2 = plot.Plot2D(parent=widget, backend=backend)
        self.plot2d2.setGraphTitle("The image can't be too small")
        self.plot2d2.setInteractiveMode('pan')
        self.plot2d2.addImage(data)
        self.plot2d2.getXAxis().setRangeConstraints(maxRange=200)
        self.plot2d2.getYAxis().setRangeConstraints(maxRange=200)

        self.plot1d = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d.setGraphTitle("The curve is clamped into the view")
        self.plot1d.addCurve(x=numpy.arange(100), y=data1d, legend="mean")
        self.plot1d.getXAxis().setLimitsConstraints(minPos=0, maxPos=100)
        self.plot1d.getYAxis().setLimitsConstraints(minPos=data1d.min(),
                                                    maxPos=data1d.max())

        self.plot1d2 = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d2.setGraphTitle("Only clamp y-axis")
        self.plot1d2.setInteractiveMode('pan')
        self.plot1d2.addCurve(x=numpy.arange(100), y=data1d, legend="mean")
        self.plot1d2.getYAxis().setLimitsConstraints(minPos=data1d.min(),
                                                     maxPos=data1d.max())

        layout.addWidget(self.plot2d, 0, 0)
        layout.addWidget(self.plot1d, 0, 1)
        layout.addWidget(self.plot2d2, 1, 0)
        layout.addWidget(self.plot1d2, 1, 1)
Esempio n. 2
0
    def __init__(self, parent=None):
        """Constructor"""
        super(DataViewer, self).__init__(parent)

        self.__plot1d = plot.Plot1D()
        self.__plot2d = plot.Plot2D()
        self.__text = qt.QLabel()
        self.__text.setAlignment(qt.Qt.AlignCenter)

        self.__index1d = self.addWidget(self.__plot1d)
        self.__index2d = self.addWidget(self.__plot2d)
        self.__indexText = self.addWidget(self.__text)
        self.setCurrentIndex(self.__indexText)
Esempio n. 3
0
 def createWidget(self, parent):
     from silx.gui import plot
     return plot.Plot1D(parent=parent)
Esempio n. 4
0
    def __init__(self):
        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Plot with synchronized axes")
        widget = qt.QWidget(self)
        self.setCentralWidget(widget)

        layout = qt.QGridLayout()
        widget.setLayout(layout)

        backend = "mpl"
        self.plot2d = plot.Plot2D(parent=widget, backend=backend)
        self.plot2d.setInteractiveMode('pan')
        self.plot1d_x1 = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d_x2 = plot.PlotWidget(parent=widget, backend=backend)
        self.plot1d_y1 = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d_y2 = plot.PlotWidget(parent=widget, backend=backend)

        data = numpy.arange(100 * 100)
        data = (data % 100) / 5.0
        data = numpy.sin(data)
        data = silx.test.utils.add_gaussian_noise(data, mean=0.01)
        data.shape = 100, 100

        self.plot2d.addImage(data)
        self.plot1d_x1.addCurve(x=numpy.arange(100),
                                y=numpy.mean(data, axis=0),
                                legend="mean")
        self.plot1d_x1.addCurve(x=numpy.arange(100),
                                y=numpy.max(data, axis=0),
                                legend="max")
        self.plot1d_x1.addCurve(x=numpy.arange(100),
                                y=numpy.min(data, axis=0),
                                legend="min")
        self.plot1d_x2.addCurve(x=numpy.arange(100), y=numpy.std(data, axis=0))

        self.plot1d_y1.addCurve(y=numpy.arange(100),
                                x=numpy.mean(data, axis=1),
                                legend="mean")
        self.plot1d_y1.addCurve(y=numpy.arange(100),
                                x=numpy.max(data, axis=1),
                                legend="max")
        self.plot1d_y1.addCurve(y=numpy.arange(100),
                                x=numpy.min(data, axis=1),
                                legend="min")
        self.plot1d_y2.addCurve(y=numpy.arange(100), x=numpy.std(data, axis=1))

        self.constraint1 = SyncAxes([
            self.plot2d.getXAxis(),
            self.plot1d_x1.getXAxis(),
            self.plot1d_x2.getXAxis()
        ])
        self.constraint2 = SyncAxes([
            self.plot2d.getYAxis(),
            self.plot1d_y1.getYAxis(),
            self.plot1d_y2.getYAxis()
        ])
        self.constraint3 = SyncAxes(
            [self.plot1d_x1.getYAxis(),
             self.plot1d_y1.getXAxis()])
        self.constraint4 = SyncAxes(
            [self.plot1d_x2.getYAxis(),
             self.plot1d_y2.getXAxis()])

        layout.addWidget(self.plot2d, 0, 0)
        layout.addWidget(self.createCenteredLabel(u"↓↑"), 1, 0)
        layout.addWidget(self.plot1d_x1, 2, 0)
        layout.addWidget(self.createCenteredLabel(u"↓↑"), 3, 0)
        layout.addWidget(self.plot1d_x2, 4, 0)
        layout.addWidget(self.createCenteredLabel(u"→\n←"), 0, 1)
        layout.addWidget(self.plot1d_y1, 0, 2)
        layout.addWidget(self.createCenteredLabel(u"→\n←"), 0, 3)
        layout.addWidget(self.plot1d_y2, 0, 4)
        layout.addWidget(self.createCenteredLabel(u"↗↙"), 2, 2)
        layout.addWidget(self.createCenteredLabel(u"↗↙"), 4, 4)
Esempio n. 5
0
    def __init__(self, parent=None):
        super(IECwindow, self).__init__(parent)  #qt.QMainWindow.__init__(self)
        #self.setWindowTitle("Plot with synchronized axes")
        widget = qt.QWidget(self)
        self.setCentralWidget(widget)
        self.updateThread = None
        layout = qt.QGridLayout()
        widget.setLayout(layout)
        backend = "mpl"
        #self.plot2d_cormap = plot.Plot2D(parent=widget, backend=backend)
        #self.plot2d.setInteractiveMode('pan')
        self.plot1d_chromo = self.createChromoPLot(widget, backend)
        self.plot1d_chromo.getYAxis().setLimits(-0.05, 1.05)
        self.plot1d_chromo.getYAxis().setAutoScale(flag=False)

        self.plot1d_log = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d_subchromo = self.createChromoPLot(widget, backend)
        self.plot1d_ratio = self.createChromoPLot(widget, backend)
        self.plot1d_log.getYAxis().setScale("log")

        self.frameSlider = self.createFrameSlider(widget)
        self.diffSlider = self.createDiffSlider(widget)

        self.saveButton = self.createSaveButton(widget)

        self.l1 = QLabel(str(self.plot1d_chromo.getXAxis().getLimits()[0]) +
                         "," + str(self.frameSlider.minimum),
                         parent=widget)
        self.l1.setAlignment(Qt.AlignCenter)

        clearAction = ClearButton(self.plot1d_ratio, parent=widget)
        #actions_menu =   self.plot1d_ratio.menuBar().addMenu("Custom actions")
        toolbar = qt.QToolBar("My toolbar")
        self.plot1d_ratio.addToolBar(toolbar)
        #actions_menu.addAction(clearAction)
        toolbar.addAction(clearAction)

        self.constraint3 = SyncAxes([
            self.plot1d_chromo.getXAxis(),
            self.plot1d_subchromo.getXAxis(),
            self.plot1d_ratio.getXAxis()
        ])  #],self.plot2d_cormap.getXAxis(),self.plot2d_cormap.getYAxis()])
        #self.constraint3 = SyncAxes([self.plot1d_chromo.getXAxis(), self.plot1d_ratio.getXAxis()])
        #self.constraint1 = SyncAxes([self.plot1d_log.getXAxis(), self.plot1d_loglog.getXAxis(),self.plot1d_kratky.getXAxis(),self.plot1d_holtzer.getXAxis()], syncScale=False)

        #self.plot1d_kratky.getYAxis().setLimits(0,medfilt(I*self.q*self.q,21).max())
        layout.addWidget(self.plot1d_chromo, 0, 0)
        layout.addWidget(self.plot1d_log, 0, 1, 2, 1)

        layout.addWidget(self.frameSlider, 1, 0)
        layout.addWidget(self.diffSlider, 2, 0)
        layout.addWidget(self.plot1d_subchromo, 3, 0)
        layout.addWidget(self.plot1d_ratio, 3, 1)
        layout.addWidget(self.saveButton, 4, 1)
        #layout.addWidget(self.l1)

        currentRoi = self.plot1d_log.getCurvesRoiWidget().getRois()
        print(currentRoi)
        if len(currentRoi) == 0:
            currentRoi = OrderedDict(
                {"low-q range": {
                    "from": 0.1,
                    "to": 1,
                    "type": "X"
                }})
        else:
            currentRoi.update(
                {"low-q range": {
                    "from": 0.1,
                    "to": 1,
                    "type": "X"
                }})
        print(currentRoi)
        self.plot1d_log.getCurvesRoiWidget().setRois(currentRoi)
Esempio n. 6
0
 def createChromoPLot(self, widget, backend):
     chromo = plot.Plot1D(parent=widget, backend=backend)
     chromo.getXAxis().sigLimitsChanged.connect(self.chromLimitsChanged)
     return chromo