Beispiel #1
0
    def __init__(self, parent=None):
        Plot2D.__init__(self, parent)

        self._toolbar = qt.QToolBar(self)
        self.addToolBar(self._toolbar)
        pluginsToolButton = PluginsToolButton(plot=self, parent=self,
                                              method="getPlugin2DInstance")

        if PLUGINS_DIR:
            pluginsToolButton.getPlugins(
                    method="getPlugin2DInstance",
                    directoryList=PLUGINS_DIR)
        self._toolbar.addWidget(pluginsToolButton)
Beispiel #2
0
def main():
    # open and show data (convert it to h5 to be loaded)
    dataPath = "data/Pilatus1M.hdf5"
    import h5py
    import numpy
    #select the cube values:
    f = h5py.File(dataPath)
    # then select the 'Data/qspace' datagroup (array containing the cubes of the isosurface )
    data = f['data']
    data = numpy.array(data, order='C', dtype='float32')

    ## Plot the data
    from silx.gui.plot import Plot2D

    plot = Plot2D()
    plot.setKeepDataAspectRatio(True)
    colormap = {
        'name': 'inferno',
        'normalization': 'log',
        'autoscale': True,
        'vmin': 0.0,
        'vmax': 1.0
    }
    plot.setDefaultColormap(colormap)
    plot.addImage(data)
    plot.show()

    # do the azimutal integration
    radii = computeradius(data, xcenter=180, ycenter=260)

    # TODO create the histogram of the radii
    # ...

    # TODO : display the histogram of radii
    from silx.gui.plot import Plot1D
Beispiel #3
0
    def setUp(self):
        super(TestColorBarWidget, self).setUp()
        self.plot = Plot2D()
        self.colorBar = self.plot.getColorBarWidget()
        self.colorBar.setVisible(True)  # Makes sure the colormap is visible

        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
Beispiel #4
0
    def plot_data2D(self,
                    data2D,
                    dataX,
                    dataY,
                    tabs_canvas_index,
                    plot_canvas_index,
                    title="",
                    xtitle="",
                    ytitle=""):
        origin = (dataX[0], dataY[0])
        scale = (dataX[1] - dataX[0], dataY[1] - dataY[0])

        data_to_plot = data2D.T

        colormap = {
            "name": "temperature",
            "normalization": "linear",
            "autoscale": True,
            "vmin": 0,
            "vmax": 0,
            "colors": 256
        }

        self.plot_canvas[plot_canvas_index] = Plot2D()

        self.plot_canvas[plot_canvas_index].resetZoom()
        self.plot_canvas[plot_canvas_index].setXAxisAutoScale(True)
        self.plot_canvas[plot_canvas_index].setYAxisAutoScale(True)
        self.plot_canvas[plot_canvas_index].setGraphGrid(False)
        self.plot_canvas[plot_canvas_index].setKeepDataAspectRatio(True)
        self.plot_canvas[plot_canvas_index].yAxisInvertedAction.setVisible(
            False)

        self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(False)
        self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(False)

        self.plot_canvas[plot_canvas_index].getMaskAction().setVisible(False)
        self.plot_canvas[plot_canvas_index].getRoiAction().setVisible(False)
        self.plot_canvas[plot_canvas_index].getColormapAction().setVisible(
            False)
        self.plot_canvas[plot_canvas_index].setKeepDataAspectRatio(False)

        self.plot_canvas[plot_canvas_index].addImage(numpy.array(data_to_plot),
                                                     legend="image1",
                                                     scale=scale,
                                                     origin=origin,
                                                     colormap=colormap,
                                                     replace=True)

        self.plot_canvas[plot_canvas_index].setActiveImage("image1")

        self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle)
        self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle)
        self.plot_canvas[plot_canvas_index].setGraphTitle(title)

        self.tab[tabs_canvas_index].layout().addWidget(
            self.plot_canvas[plot_canvas_index])
Beispiel #5
0
    def __init__(self, parent=None):
        Plot2D.__init__(self, parent=parent)
        self.toolBar().addSeparator()
        label = qt.QLabel(self)
        label.setText("Median filter width:")

        self.spinbox = qt.QSpinBox(self)
        self.spinbox.setMinimum(1)
        self.spinbox.setValue(1)
        self.spinbox.setSingleStep(2)
        self.spinbox.valueChanged[int].connect(self._medfiltWidthChanged)
        self.spinbox.setEnabled(False)

        self.toolBar().addWidget(label)
        self.toolBar().addWidget(self.spinbox)

        self._data = None
        self._legend = None
        self._colormap = None
Beispiel #6
0
    def _createPlot2D(self):
        plot = Plot2D(self)
        self.plot = plot

        toolBar = toolbar.ProfileToolBar(plot, plot)
        toolBar.setScheme("image")
        plot.addToolBar(toolBar)

        toolBar = plot.getProfileToolbar()
        toolBar.clear()
Beispiel #7
0
    def __init__(self, parent=None):
        Plot2D.__init__(self, parent=parent)
        self.toolBar().addSeparator()
        label = qt.QLabel(self)
        label.setText("Median filter width:")

        self.spinbox = qt.QSpinBox(self)
        self.spinbox.setMinimum(1)
        self.spinbox.setValue(1)
        self.spinbox.setSingleStep(2)
        self.spinbox.valueChanged[int].connect(self._medfiltWidthChanged)
        self.spinbox.setEnabled(False)

        self.toolBar().addWidget(label)
        self.toolBar().addWidget(self.spinbox)

        self._data = None
        self._legend = None
        self._colormap = None
Beispiel #8
0
    def setUp(self):
        super(TestColorBarUpdate, self).setUp()
        self.plot = Plot2D()
        self.colorBar = self.plot.getColorBarWidget()
        self.colorBar.setVisible(True)  # Makes sure the colormap is visible
        self.colorBar.setPlot(self.plot)

        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
        self.data = numpy.random.rand(9).reshape(3, 3)
Beispiel #9
0
    def setUp(self):
        super(TestNoAutoscale, self).setUp()
        self.plot = Plot2D()
        self.colorBar = self.plot.getColorBarWidget()
        self.colorBar.setVisible(True)  # Makes sure the colormap is visible
        self.tickBar = self.colorBar.getColorScaleBar().getTickBar()
        self.colorScale = self.colorBar.getColorScaleBar().getColorScale()

        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
Beispiel #10
0
 def createImageContext(self):
     self.plot2d = Plot2D()
     self._imgLgd = 'test image'
     self.imageData = numpy.arange(32*128).reshape(32, 128)
     self.plot2d.addImage(data=self.imageData,
                          legend=self._imgLgd, replace=False)
     self.imageContext = stats._ImageContext(
         item=self.plot2d.getImage(self._imgLgd),
         plot=self.plot2d,
         onlimits=False
     )
Beispiel #11
0
def create_plot2d():
    from silx.gui.plot import Plot2D
    global app  # QApplication must be global to avoid seg fault on quit
    app = qt.QApplication([])
    plot = Plot2D()  # Create the plot widget
    plot.setAttribute(qt.Qt.WA_DeleteOnClose)
    plot.setKeepDataAspectRatio(
        False)  # To keep aspect ratio between X and Y axes
    plot.show()  # Make the plot widget visible
    plot.setFocus(qt.Qt.OtherFocusReason)
    return plot
Beispiel #12
0
 def testProfile1D(self):
     plot = Plot2D()
     plot.show()
     self.qWaitForWindowExposed(plot)
     plot.addImage([[0, 1], [2, 3]])
     self.assertIsInstance(plot.getProfileToolbar().getProfileMainWindow(),
                           qt.QMainWindow)
     self.assertIsInstance(plot.getProfilePlot(), Plot1D)
     plot.setAttribute(qt.Qt.WA_DeleteOnClose)
     plot.close()
     del plot
Beispiel #13
0
    def plot_data2D(self,
                    data2D,
                    dataX,
                    dataY,
                    title="",
                    xtitle="",
                    ytitle=""):
        if self.plot_canvas is None:
            self.plot_canvas = Plot2D()

            self.plot_canvas.resetZoom()
            self.plot_canvas.setXAxisAutoScale(True)
            self.plot_canvas.setYAxisAutoScale(True)
            self.plot_canvas.setGraphGrid(False)
            self.plot_canvas.setKeepDataAspectRatio(False)
            self.plot_canvas.yAxisInvertedAction.setVisible(False)

            self.plot_canvas.setXAxisLogarithmic(False)
            self.plot_canvas.setYAxisLogarithmic(False)
            self.plot_canvas.getMaskAction().setVisible(False)
            self.plot_canvas.getRoiAction().setVisible(False)
            self.plot_canvas.getColormapAction().setVisible(True)

        origin = (dataX[0], dataY[0])
        scale = (dataX[1] - dataX[0], dataY[1] - dataY[0])

        self.plot_canvas.addImage(numpy.array(data2D.T),
                                  legend="power",
                                  scale=scale,
                                  origin=origin,
                                  colormap={
                                      "name": "temperature",
                                      "normalization": "linear",
                                      "autoscale": True,
                                      "vmin": 0,
                                      "vmax": 0,
                                      "colors": 256
                                  },
                                  replace=True)

        self.plot_canvas.setActiveImage("power")

        self.plot_canvas.setGraphXLabel(xtitle)
        self.plot_canvas.setGraphYLabel(ytitle)
        self.plot_canvas.setGraphTitle(title)

        self.plot_canvas.resetZoom()
        self.plot_canvas.setXAxisAutoScale(True)
        self.plot_canvas.setYAxisAutoScale(True)

        layout = self.layout()
        layout.addWidget(self.plot_canvas)
        self.setLayout(layout)
    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 = "gl"
        plots = []

        data = numpy.arange(100 * 100)
        data = (data % 100) / 5.0
        data = numpy.sin(data)
        data.shape = 100, 100

        colormaps = ["gray", "red", "green", "blue"]
        for i in range(2 * 2):
            plot = Plot2D(parent=widget, backend=backend)
            plot.setInteractiveMode('pan')
            plot.setDefaultColormap(Colormap(colormaps[i]))
            noisyData = silx.test.utils.add_gaussian_noise(data, mean=i / 10.0)
            plot.addImage(noisyData)
            plots.append(plot)

        xAxis = [p.getXAxis() for p in plots]
        yAxis = [p.getYAxis() for p in plots]

        self.constraint1 = SyncAxes(xAxis,
                                    syncLimits=False,
                                    syncScale=True,
                                    syncDirection=True,
                                    syncCenter=True,
                                    syncZoom=True)
        self.constraint2 = SyncAxes(yAxis,
                                    syncLimits=False,
                                    syncScale=True,
                                    syncDirection=True,
                                    syncCenter=True,
                                    syncZoom=True)

        for i, plot in enumerate(plots):
            if i % 2 == 0:
                plot.setFixedWidth(400)
            else:
                plot.setFixedWidth(500)
            if i // 2 == 0:
                plot.setFixedHeight(400)
            else:
                plot.setFixedHeight(500)
            layout.addWidget(plot, i // 2, i % 2)
    def plot_2D(self, plot_canvas, profile_1D, last_index=-1, show=False):
        X, Y, data2D = self.create_2D_profile(profile_1D, last_index)

        dataX = X[0, :]
        dataY = Y[:, 0]

        origin = (dataX[0], dataY[0])
        scale = (dataX[1] - dataX[0], dataY[1] - dataY[0])

        colormap = {
            "name": "temperature",
            "normalization": "linear",
            "autoscale": True,
            "vmin": 0,
            "vmax": 0,
            "colors": 256
        }

        if plot_canvas is None:
            plot_canvas = Plot2D()

            plot_canvas.resetZoom()
            plot_canvas.setXAxisAutoScale(True)
            plot_canvas.setYAxisAutoScale(True)
            plot_canvas.setGraphGrid(False)
            plot_canvas.setKeepDataAspectRatio(True)
            plot_canvas.yAxisInvertedAction.setVisible(False)

            plot_canvas.setXAxisLogarithmic(False)
            plot_canvas.setYAxisLogarithmic(False)

            plot_canvas.getMaskAction().setVisible(False)
            plot_canvas.getRoiAction().setVisible(False)
            plot_canvas.getColormapAction().setVisible(True)
            plot_canvas.setKeepDataAspectRatio(False)

        plot_canvas.clear()
        plot_canvas.addImage(numpy.array(data2D),
                             legend="rotated",
                             scale=scale,
                             origin=origin,
                             colormap=colormap,
                             replace=True)

        plot_canvas.setActiveImage("rotated")
        plot_canvas.setGraphXLabel("X [m]")
        plot_canvas.setGraphYLabel("Y [m]")
        plot_canvas.setGraphTitle("2D Intensity Profile")

        if show: plot_canvas.show()

        return plot_canvas
Beispiel #16
0
 def createScatterContext(self):
     self.scatterPlot = Plot2D()
     lgd = 'scatter plot'
     self.xScatterData = numpy.array([0, 1, 2, 20, 50, 60, 36])
     self.yScatterData = numpy.array([2, 3, 4, 26, 69, 6, 18])
     self.valuesScatterData = numpy.array([5, 6, 7, 10, 90, 20, 5])
     self.scatterPlot.addScatter(self.xScatterData, self.yScatterData,
                                 self.valuesScatterData, legend=lgd)
     self.scatterContext = stats._ScatterContext(
         item=self.scatterPlot.getScatter(lgd),
         plot=self.scatterPlot,
         onlimits=False
     )
Beispiel #17
0
    def __init__(self, parent=None):
        qt.QMainWindow.__init__(self, parent)
        self.u = Ui_MainWindow()
        self.u.setupUi(self)

        self.datDir = "/Users/uemura/OneDrive/UU/Urbana-Champaign/20181112 Ti-doped Fe2O3 (10%)/"
        self.trimRange = [200, 300]
        self.TopPP = glob.glob(
            self.datDir + '/' +
            'GCR1_10%TiO2inFe2O3_1.3mW400nm_600ms1f_20181112-1_r*_s*Top_PP.txt'
        )
        self.TopPr = glob.glob(
            self.datDir + '/' +
            'GCR1_10%TiO2inFe2O3_1.3mW400nm_600ms1f_20181112-1_r*_s*Top_Pr.txt'
        )
        self.BotPP = glob.glob(
            self.datDir + '/' +
            'GCR1_10%TiO2inFe2O3_1.3mW400nm_600ms1f_20181112-1_r*_s*Bot_PP.txt'
        )
        self.BotPr = glob.glob(
            self.datDir + '/' +
            'GCR1_10%TiO2inFe2O3_1.3mW400nm_600ms1f_20181112-1_r*_s*Bot_Pr.txt'
        )
        self.runNum = -1
        self.scanNum = -1
        self.thrhld = 0.004
        self.fcommon = 'GCR1_10%TiO2inFe2O3_1.3mW400nm_600ms1f_20181112-1'
        self.I = 0
        self.timer = qt.QBasicTimer()

        self.plot = Plot2D()
        self.plot.show()
        self.show()

        def openDirectory():
            self.datDir = self.u.tB_Directory.toPlainText()
            dat_dir = os.environ["HOME"]
            if self.datDir != "" and os.path.isdir(self.datDir):
                dat_dir = self.datDir
            FO_dialog = qt.QFileDialog()
            directory = FO_dialog.getExistingDirectory(
                None, caption="Select a directory", directory=dat_dir)
            if directory:
                self.u.tB_Directory.clear()
                self.u.tB_Directory.append(directory)

        # def convert():
        # print (self.u.tE_header.toPlainText())

        self.u.pB_open.clicked.connect(openDirectory)
        self.u.pB_convert.clicked.connect(self.DoAction)
Beispiel #18
0
 def __init__(self, parent=None, backend="gl"):
     super(SilxScatterWindow, self).__init__(parent)
     self.mainLayout = qt.QVBoxLayout(self)
     self._defaultSymbol = "s"
     self._defaultColormap = Colormap("temperature")
     self.plot = Plot2D(self, backend=backend)
     self.plot.setColormap(self._defaultColormap)
     self.plot.getPlotWidget().setDataMargins(0.05, 0.05, 0.05, 0.05)
     self.mainLayout.addWidget(self.plot)
     self._plotEnabled = True
     self.dataObjectsList = []
     self.dataObjectsDict = {}
     self._xLabel = "X"
     self._yLabel = "Y"
Beispiel #19
0
    def __init__(self, parent):
        super(_PlotWithWaitingLabel, self).__init__(parent=parent)
        layout = qt.QStackedLayout(self)
        layout.setStackingMode(qt.QStackedLayout.StackAll)

        self._waiting_label = qt.QLabel(parent=self)
        self._waiting_label.setAlignment(qt.Qt.AlignHCenter | qt.Qt.AlignVCenter)
        layout.addWidget(self._waiting_label)

        self._plot = Plot2D(parent=self)
        layout.addWidget(self._plot)

        self.updateThread = _PlotWithWaitingLabel.AnimationThread(self._waiting_label)
        self.updateThread.start()
Beispiel #20
0
def plot_power_density(x_coord, y_coord, power_density, total_power):
    origin = (x_coord[0], y_coord[0])
    scale = (x_coord[1] - x_coord[0], y_coord[1] - y_coord[0])
    area = scale[0] * scale[1]

    data_to_plot = power_density.T

    colormap = {
        "name": "temperature",
        "normalization": "linear",
        "autoscale": True,
        "vmin": 0,
        "vmax": 0,
        "colors": 256
    }

    plot_canvas = Plot2D()

    plot_canvas.resetZoom()
    plot_canvas.setXAxisAutoScale(True)
    plot_canvas.setYAxisAutoScale(True)
    plot_canvas.setGraphGrid(False)
    plot_canvas.setKeepDataAspectRatio(True)
    plot_canvas.yAxisInvertedAction.setVisible(False)

    plot_canvas.setXAxisLogarithmic(False)
    plot_canvas.setYAxisLogarithmic(False)
    plot_canvas.getMaskAction().setVisible(False)
    plot_canvas.getRoiAction().setVisible(False)
    plot_canvas.getColormapAction().setVisible(True)
    plot_canvas.setKeepDataAspectRatio(False)

    plot_canvas.addImage(numpy.array(data_to_plot),
                         legend="Power Density",
                         scale=scale,
                         origin=origin,
                         colormap=colormap,
                         replace=True)

    plot_canvas.setActiveImage("Power Density")
    plot_canvas.setGraphXLabel("Horizontal Position [mm]")
    plot_canvas.setGraphYLabel("Vertical Position [mm]")
    plot_canvas.setGraphTitle("Power Density [nW/mm^2]\nTotal Power = " +
                              str(round(total_power, 6)) + "(" +
                              str(round(power_density.sum() * area, 6)) +
                              ") nW")

    plot_canvas.show()
def main():
    global app
    app = qt.QApplication([])

    # Create a Plot2D, set its limits and display it
    plot2d = Plot2D()
    plot2d.getIntensityHistogramAction().setVisible(True)
    plot2d.setLimits(0, Nx, 0, Ny)
    plot2d.getDefaultColormap().setVRange(0., 1.5)
    plot2d.show()

    # Create the thread that calls submitToQtMainThread
    updateThread = UpdateThread(plot2d)
    updateThread.start()  # Start updating the plot

    app.exec()

    updateThread.stop()  # Stop updating the plot
Beispiel #22
0
    def __init__(self, parent=None, mode=None):
        qt.QMainWindow.__init__(self, parent)
        self.plot = Plot2D()
        self.setCentralWidget(self.plot)

        # 1D roi management
        self._curveRoiWidget = self.plot.getCurvesRoiDockWidget().widget()
        # hide last columns which are of no use now
        for index in (5, 6, 7, 8):
            self._curveRoiWidget.roiTable.setColumnHidden(index, True)

        # 2D - 3D roi manager
        self._regionManager = RegionOfInterestManager(parent=self.plot)

        # Create the table widget displaying
        self._2DRoiWidget = RegionOfInterestTableWidget()
        self._2DRoiWidget.setRegionOfInterestManager(self._regionManager)

        # tabWidget for displaying the rois
        self._roisTabWidget = qt.QTabWidget(parent=self)
        if hasattr(self._roisTabWidget, 'setTabBarAutoHide'):
            self._roisTabWidget.setTabBarAutoHide(True)

        # widget for displaying stats results and update mode
        self._statsWidget = _RoiStatsWidget(parent=self, plot=self.plot)

        # create Dock widgets
        self._roisTabWidgetDockWidget = qt.QDockWidget(parent=self)
        self._roisTabWidgetDockWidget.setWidget(self._roisTabWidget)
        self.addDockWidget(qt.Qt.RightDockWidgetArea,
                           self._roisTabWidgetDockWidget)

        # create Dock widgets
        self._roiStatsWindowDockWidget = qt.QDockWidget(parent=self)
        self._roiStatsWindowDockWidget.setWidget(self._statsWidget)
        # move the docker contain in the parent widget
        self.addDockWidget(qt.Qt.RightDockWidgetArea,
                           self._statsWidget._docker)
        self.addDockWidget(qt.Qt.RightDockWidgetArea,
                           self._roiStatsWindowDockWidget)

        # expose API
        self.setUpdateMode = self._statsWidget.setUpdateMode
    def __init__(self, parent=None):
        """

        :param parent: Parent QWidget
        """
        super(ArrayImagePlot, self).__init__(parent)

        self.__signals = None
        self.__signals_names = None
        self.__x_axis = None
        self.__x_axis_name = None
        self.__y_axis = None
        self.__y_axis_name = None

        self._plot = Plot2D(self)
        self._plot.setDefaultColormap(
            Colormap(name="viridis",
                     vmin=None,
                     vmax=None,
                     normalization=Colormap.LINEAR))
        self._plot.getIntensityHistogramAction().setVisible(True)

        self.selectorDock = qt.QDockWidget("Data selector", self._plot)
        # not closable
        self.selectorDock.setFeatures(qt.QDockWidget.DockWidgetMovable
                                      | qt.QDockWidget.DockWidgetFloatable)
        self._selector = NumpyAxesSelector(self.selectorDock)
        self._selector.setNamedAxesSelectorVisibility(False)
        self._selector.selectionChanged.connect(self._updateImage)

        self._auxSigSlider = HorizontalSliderWithBrowser(parent=self)
        self._auxSigSlider.setMinimum(0)
        self._auxSigSlider.setValue(0)
        self._auxSigSlider.valueChanged[int].connect(self._sliderIdxChanged)
        self._auxSigSlider.setToolTip("Select auxiliary signals")

        layout = qt.QVBoxLayout()
        layout.addWidget(self._plot)
        layout.addWidget(self._auxSigSlider)
        self.selectorDock.setWidget(self._selector)
        self._plot.addTabbedDockWidget(self.selectorDock)

        self.setLayout(layout)
    def setUp(self):
        TestCaseQt.setUp(self)
        self.scatterPlot = Plot2D()
        self.scatterPlot.addScatter([0, 1, 2, 20, 50, 60],
                                    [2, 3, 4, 26, 69, 6],
                                    [5, 6, 7, 10, 90, 20],
                                    legend=self.SCATTER_LEGEND)
        self.widget = StatsWidget.StatsTable(plot=self.scatterPlot)

        mystats = statshandler.StatsHandler(
            (stats.StatMin(),
             (stats.StatCoordMin(),
              statshandler.StatFormatter(None, qt.QTableWidgetItem)),
             stats.StatMax(),
             (stats.StatCoordMax(),
              statshandler.StatFormatter(None, qt.QTableWidgetItem)),
             stats.StatDelta(), ('std', numpy.std), ('mean', numpy.mean),
             stats.StatCOM()))

        self.widget.setStats(mystats)
Beispiel #25
0
    def setUp(self):
        TestCaseQt.setUp(self)
        self.plot = Plot2D()

        self.plot.addImage(data=numpy.arange(128*128).reshape(128, 128),
                           legend='test image', replace=False)

        self.widget = StatsWidget.StatsTable(plot=self.plot)

        mystats = statshandler.StatsHandler((
            (stats.StatMin(), statshandler.StatFormatter()),
            (stats.StatCoordMin(), statshandler.StatFormatter(None, qt.QTableWidgetItem)),
            (stats.StatMax(), statshandler.StatFormatter()),
            (stats.StatCoordMax(), statshandler.StatFormatter(None, qt.QTableWidgetItem)),
            (stats.StatDelta(), statshandler.StatFormatter()),
            ('std', numpy.std),
            ('mean', numpy.mean),
            (stats.StatCOM(), statshandler.StatFormatter(None))
        ))

        self.widget.setStats(mystats)
Beispiel #26
0
    def __init__(self, parent=None):
        """

        :param parent: Parent QWidget
        """
        super(ArrayImagePlot, self).__init__(parent)

        self.__signal = None
        self.__signal_name = None
        self.__x_axis = None
        self.__x_axis_name = None
        self.__y_axis = None
        self.__y_axis_name = None

        self._plot = Plot2D(self)
        self._plot.setDefaultColormap({
            "name": "viridis",
            "vmin": 0.,
            "vmax": 1.,  # ignored (autoscale) but mandatory
            "normalization": "linear",
            "autoscale": True
        })

        self.selectorDock = qt.QDockWidget("Data selector", self._plot)
        # not closable
        self.selectorDock.setFeatures(qt.QDockWidget.DockWidgetMovable
                                      | qt.QDockWidget.DockWidgetFloatable)
        self._legend = qt.QLabel(self)
        self._selector = NumpyAxesSelector(self.selectorDock)
        self._selector.setNamedAxesSelectorVisibility(False)
        self.__selector_is_connected = False

        layout = qt.QVBoxLayout()
        layout.addWidget(self._plot)
        layout.addWidget(self._legend)
        self.selectorDock.setWidget(self._selector)
        self._plot.addTabbedDockWidget(self.selectorDock)

        self.setLayout(layout)
Beispiel #27
0
def plot2Dsilx(nodeData):
    from silx.gui.plot import Plot2D
    from silx.gui import colors

    saveType = nodeData[0]
    savedColumns = nodeData[4]
    for fname, props in savedColumns.items():
        maps = read2D(saveType, fname, props)

    # applied only to one 2D map:
    plot = Plot2D()
    plot.setGraphTitle(nodeData[1] + ' ' + saveType)
    plot.getXAxis().setLabel(label=nodeData[3][0])
    plot.getYAxis().setLabel(label=nodeData[3][1])
    xOrigin, xScale = 0, 1
    yOrigin, yScale = 0, 1
    plot.addImage(maps[0],
                  colormap=colors.Colormap('viridis'),
                  origin=(xOrigin, yOrigin),
                  scale=(xScale, yScale))
    # plot.saveGraph('test.png')
    plot.show()  # end plot2Dsilx
Beispiel #28
0
    def testProfile1D(self):
        self.plot = Plot2D()
        self.plot.show()
        self.qWaitForWindowExposed(self.plot)
        self.plot.addImage([[0, 1], [2, 3]])

        toolBar = self.plot.getProfileToolbar()

        manager = toolBar.getProfileManager()
        roiManager = manager.getRoiManager()

        roi = rois.ProfileImageHorizontalLineROI()
        roi.setPosition(0.5)
        roiManager.addRoi(roi)
        roiManager.setCurrentRoi(roi)

        for _ in range(20):
            self.qWait(200)
            if not manager.hasPendingOperations():
                break

        profileWindow = roi.getProfileWindow()
        self.assertIsInstance(roi.getProfileWindow(), qt.QMainWindow)
        self.assertIsInstance(profileWindow.getCurrentPlotWidget(), Plot1D)
    def plot_data2D(self, data2D, dataX, dataY, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", mode=2):

        for i in range(1+self.tab[tabs_canvas_index].layout().count()):
            self.tab[tabs_canvas_index].layout().removeItem(self.tab[tabs_canvas_index].layout().itemAt(i))

        if mode == 0:
            figure = FigureCanvas(gol.plot_image(data2D,
                                                 dataX,
                                                 dataY,
                                                 xtitle=xtitle,
                                                 ytitle=ytitle,
                                                 title=title,
                                                 show=False,
                                                 aspect='auto'))


            self.plot_canvas[plot_canvas_index] = figure
        else:

            origin = (dataX[0],dataY[0])
            scale = (dataX[1]-dataX[0],dataY[1]-dataY[0])

            data_to_plot = data2D.T

            colormap = {"name":"temperature", "normalization":"linear", "autoscale":True, "vmin":0, "vmax":0, "colors":256}


            if mode == 1:
                #TODO: delete: srio commented this part as it is never used
                raise Exception("Cannot use XoppyPlot.XoppyImageView()")
                # self.plot_canvas[plot_canvas_index] = XoppyPlot.XoppyImageView()
                # colormap = {"name":"temperature", "normalization":"linear", "autoscale":True, "vmin":0, "vmax":0, "colors":256}
                #
                # self.plot_canvas[plot_canvas_index]._imagePlot.setDefaultColormap(colormap)
                # self.plot_canvas[plot_canvas_index].setImage(numpy.array(data_to_plot), origin=origin, scale=scale)
            elif mode == 2:

                self.plot_canvas[plot_canvas_index] = Plot2D()

                self.plot_canvas[plot_canvas_index].resetZoom()
                self.plot_canvas[plot_canvas_index].setXAxisAutoScale(True)
                self.plot_canvas[plot_canvas_index].setYAxisAutoScale(True)
                self.plot_canvas[plot_canvas_index].setGraphGrid(False)
                self.plot_canvas[plot_canvas_index].setKeepDataAspectRatio(True)
                self.plot_canvas[plot_canvas_index].yAxisInvertedAction.setVisible(False)

                self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(False)
                self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(False)
                #silx 0.4.0
                self.plot_canvas[plot_canvas_index].getMaskAction().setVisible(False)
                self.plot_canvas[plot_canvas_index].getRoiAction().setVisible(False)
                self.plot_canvas[plot_canvas_index].getColormapAction().setVisible(False)
                self.plot_canvas[plot_canvas_index].setKeepDataAspectRatio(False)



                self.plot_canvas[plot_canvas_index].addImage(numpy.array(data_to_plot),
                                                             legend="zio billy",
                                                             scale=scale,
                                                             origin=origin,
                                                             colormap=colormap,
                                                             replace=True)

                self.plot_canvas[plot_canvas_index].setActiveImage("zio billy")

                # COLOR TABLE
                from matplotlib.image import AxesImage
                image = AxesImage(self.plot_canvas[plot_canvas_index]._backend.ax)
                image.set_data(numpy.array(data_to_plot))
                self.plot_canvas[plot_canvas_index]._backend.fig.colorbar(image, ax=self.plot_canvas[plot_canvas_index]._backend.ax)

            self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle)
            self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle)
            self.plot_canvas[plot_canvas_index].setGraphTitle(title)

        self.tab[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index])
Beispiel #30
0
 def createWidget(self, parent):
     plot = Plot2D(parent=parent)
     plot.setAutoReplot(False)
     return plot
Beispiel #31
0

def dummy_image():
    """Create a dummy image"""
    x = numpy.linspace(-1.5, 1.5, 1024)
    xv, yv = numpy.meshgrid(x, x)
    signal = numpy.exp(-(xv**2 / 0.15**2 + yv**2 / 0.25**2))
    # add noise
    signal += 0.3 * numpy.random.random(size=signal.shape)
    return signal


app = qt.QApplication([])  # Start QApplication

# Create the plot widget and add an image
plot = Plot2D()
plot.getDefaultColormap().setName('viridis')
plot.setKeepDataAspectRatio(True)
plot.addImage(dummy_image())

toolbar = qt.QToolBar()
toolbar.addAction(control_actions.OpenGLAction(parent=toolbar, plot=plot))
plot.addToolBar(toolbar)

# Create the object controlling the ROIs and set it up
roiManager = RegionOfInterestManager(plot)
roiManager.setColor('pink')  # Set the color of ROI


# Set the name of each created region of interest
def updateAddedRegionOfInterest(roi):