コード例 #1
0
ファイル: testProfile.py プロジェクト: tifuchs/silx
 def defaultPlot(self):
     try:
         widget = silx_plot.PlotWidget()
         widget.show()
         self.qWaitForWindowExposed(widget)
         yield widget
     finally:
         widget.close()
         widget = None
         self.qWait()
コード例 #2
0
ファイル: CompareImages.py プロジェクト: schooft/silx
    def __init__(self, parent=None, backend=None):
        qt.QMainWindow.__init__(self, parent)
        self._resetZoomActive = True
        self._colormap = Colormap()
        """Colormap shared by all modes, except the compose images (rgb image)"""
        self._colormapKeyPoints = Colormap('spring')
        """Colormap used for sift keypoints"""

        if parent is None:
            self.setWindowTitle('Compare images')
        else:
            self.setWindowFlags(qt.Qt.Widget)

        self.__transformation = None
        self.__raw1 = None
        self.__raw2 = None
        self.__data1 = None
        self.__data2 = None
        self.__previousSeparatorPosition = None

        self.__plot = plot.PlotWidget(parent=self, backend=backend)
        self.__plot.setDefaultColormap(self._colormap)
        self.__plot.getXAxis().setLabel('Columns')
        self.__plot.getYAxis().setLabel('Rows')
        if silx.config.DEFAULT_PLOT_IMAGE_Y_AXIS_ORIENTATION == 'downward':
            self.__plot.getYAxis().setInverted(True)

        self.__plot.setKeepDataAspectRatio(True)
        self.__plot.sigPlotSignal.connect(self.__plotSlot)
        self.__plot.setAxesDisplayed(False)

        self.setCentralWidget(self.__plot)

        legend = VisualizationMode.VERTICAL_LINE.name
        self.__plot.addXMarker(0,
                               legend=legend,
                               text='',
                               draggable=True,
                               color='blue',
                               constraint=self.__separatorConstraint)
        self.__vline = self.__plot._getMarker(legend)

        legend = VisualizationMode.HORIZONTAL_LINE.name
        self.__plot.addYMarker(0,
                               legend=legend,
                               text='',
                               draggable=True,
                               color='blue',
                               constraint=self.__separatorConstraint)
        self.__hline = self.__plot._getMarker(legend)

        # default values
        self.__visualizationMode = ""
        self.__alignmentMode = ""
        self.__keypointsVisible = True

        self.setAlignmentMode(AlignmentMode.ORIGIN)
        self.setVisualizationMode(VisualizationMode.VERTICAL_LINE)
        self.setKeypointsVisible(False)

        # Toolbars

        self._createToolBars(self.__plot)
        if self._interactiveModeToolBar is not None:
            self.addToolBar(self._interactiveModeToolBar)
        if self._imageToolBar is not None:
            self.addToolBar(self._imageToolBar)
        if self._compareToolBar is not None:
            self.addToolBar(self._compareToolBar)

        # Statusbar

        self._createStatusBar(self.__plot)
        if self._statusBar is not None:
            self.setStatusBar(self._statusBar)
コード例 #3
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)