def setUp(self): super(TestProfileToolBar, self).setUp() profileWindow = PlotWindow() self.plot = PlotWindow() self.toolBar = Profile.ProfileToolBar( plot=self.plot, profileWindow=profileWindow) self.plot.addToolBar(self.toolBar) self.plot.show() self.qWaitForWindowExposed(self.plot) profileWindow.show() self.qWaitForWindowExposed(profileWindow) self.mouseMove(self.plot) # Move to center self.qapp.processEvents()
def testCustomProfileWindow(self): from silx.gui.plot import ProfileMainWindow self.plot = PlotWindow() profileWindow = ProfileMainWindow.ProfileMainWindow(self.plot) toolBar = Profile.ProfileToolBar(parent=self.plot, plot=self.plot, profileWindow=profileWindow) self.plot.show() self.qWaitForWindowExposed(self.plot) profileWindow.show() self.qWaitForWindowExposed(profileWindow) self.qapp.processEvents() self.plot.addImage(numpy.arange(10 * 10).reshape(10, -1)) profile = rois.ProfileImageHorizontalLineROI() profile.setPosition(5) toolBar.getProfileManager().getRoiManager().addRoi(profile) toolBar.getProfileManager().getRoiManager().setCurrentRoi(profile) for _ in range(20): self.qWait(200) if not toolBar.getProfileManager().hasPendingOperations(): break # There is a displayed profile self.assertIsNotNone(profileWindow.getProfile()) self.assertIs(toolBar.getProfileMainWindow(), profileWindow) # There is nothing anymore but the window is still there toolBar.getProfileManager().clearProfile() self.qapp.processEvents() self.assertIsNone(profileWindow.getProfile())
def __init__(self, parent=None): qt.QWidget.__init__(self, parent) self.setWindowTitle("Strip and SNIP Configuration Window") self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(2) self.parametersWidget = StripParametersWidget(self) self.graphWidget = PlotWindow(self, position=False, aspectRatio=False, colormap=False, yInverted=False, roi=False, mask=False, fit=False) toolBar = self.graphWidget.getInteractiveModeToolBar() toolBar.getZoomModeAction().setVisible(False) toolBar.getPanModeAction().setVisible(False) self.mainLayout.addWidget(self.parametersWidget) self.mainLayout.addWidget(self.graphWidget) self.getParameters = self.parametersWidget.getParameters self.setParameters = self.parametersWidget.setParameters self._x = None self._y = None self.parametersWidget.sigStripParametersWidgetSignal.connect( \ self._slot)
def __init__(self, parent=None, initdict=None): qt.QWidget.__init__(self, parent) self.l = qt.QVBoxLayout(self) self.l.setContentsMargins(0, 0, 0, 0) self.l.setSpacing(0) self.tubeWidget = TubeWidget(self, initdict=initdict) self.setParameters = self.tubeWidget.setParameters self.getParameters = self.tubeWidget.getParameters label = qt.QLabel(self) hbox = qt.QWidget(self) hboxl = qt.QHBoxLayout(hbox) hboxl.setContentsMargins(0, 0, 0, 0) hboxl.setSpacing(0) self.plotButton = qt.QPushButton(hbox) self.plotButton.setText("Plot Continuum") self.exportButton = qt.QPushButton(hbox) self.exportButton.setText("Export to Fit") #grid.addWidget(self.plotButton, 7, 1) #grid.addWidget(self.exportButton, 7, 3) hboxl.addWidget(self.plotButton) hboxl.addWidget(self.exportButton) self.l.addWidget(self.tubeWidget) f = label.font() f.setItalic(1) label.setFont(f) label.setAlignment(qt.Qt.AlignRight) label.setText("H. Ebel, X-Ray Spectrometry 28 (1999) 255-266 ") self.l.addWidget(label) self.l.addWidget(hbox) self.graph = PlotWindow(self, colormap=False, yInverted=False, aspectRatio=False, control=False, position=False, roi=False, mask=False, fit=False) self.pluginsToolButton = PluginsToolButton(plot=self.graph) self.graph.toolBar().addWidget(self.pluginsToolButton) self.graph.getInteractiveModeToolBar().getZoomModeAction().setVisible( False) self.graph.getInteractiveModeToolBar().getPanModeAction().setVisible( False) self.l.addWidget(self.graph) self.graph.setGraphXLabel("Energy (keV)") self.graph.setGraphYLabel("photons/sr/mA/keV/s") self.plotButton.clicked.connect(self.plot) self.exportButton.clicked.connect(self._export)
def __init__(self, parent=None, analyzer=None, backend=None): super(XASMdiArea, self).__init__(parent) if analyzer is None: analyzer = XASClass.XASClass() self.analyzer = analyzer #self.setActivationOrder(qt.QMdiArea.CreationOrder) self._windowDict = {} self._windowList = ["Spectrum", "Post-edge", "Signal", "FT"] self._windowList.reverse() for title in self._windowList: plot = PlotWindow(self, position=True, aspectRatio=False, colormap=False, yInverted=False, roi=False, mask=False, fit=False, backend=backend) toolbar = plot.getInteractiveModeToolBar() toolbar.getZoomModeAction().setVisible(False) toolbar.getPanModeAction().setVisible(False) pluginsToolButton = PluginsToolButton(plot=plot) plot.toolBar().addWidget(pluginsToolButton) plot.setWindowTitle(title) self.addSubWindow(plot) self._windowDict[title] = plot plot.setDataMargins(0, 0, 0.025, 0.025) self._windowList.reverse() self.setActivationOrder(qt.QMdiArea.StackingOrder) self.tileSubWindows()
def setUp(self): super(TestPositionInfo, self).setUp() self.plot = PlotWindow() self.plot.show() self.qWaitForWindowExposed(self.plot) self.mouseMove(self.plot, pos=(1, 1)) self.qapp.processEvents() self.qWait(100)
def setUp(self): super(TestCurvesROIWidget, self).setUp() self.plot = PlotWindow() self.plot.show() self.qWaitForWindowExposed(self.plot) self.widget = CurvesROIWidget.CurvesROIDockWidget(plot=self.plot, name='TEST') self.widget.show() self.qWaitForWindowExposed(self.widget)
def setUp(self): super(TestScatterProfileToolBar, self).setUp() self.plot = PlotWindow() self.manager = manager.ProfileManager(plot=self.plot) self.manager.setItemType(scatter=True) self.manager.setActiveItemTracking(True) self.plot.show() self.qWaitForWindowExposed(self.plot)
def setUp(self): super(TestCurvesROIWidget, self).setUp() self.plot = PlotWindow() self.plot.show() self.qWaitForWindowExposed(self.plot) self.widget = self.plot.getCurvesRoiDockWidget() self.widget.show() self.qWaitForWindowExposed(self.widget)
def setUp(self): super(TestScatterProfileToolBar, self).setUp() self.plot = PlotWindow() self.profile = profile.ScatterProfileToolBar(plot=self.plot) self.plot.addToolBar(self.profile) self.plot.show() self.qWaitForWindowExposed(self.plot)
def setUp(self): super(TestRegionOfInterestManager, self).setUp() self.plot = PlotWindow() self.roiTableWidget = roi.RegionOfInterestTableWidget() dock = qt.QDockWidget() dock.setWidget(self.roiTableWidget) self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, dock) self.plot.show() self.qWaitForWindowExposed(self.plot)
def setUp(self): super(TestMaskToolsWidget, self).setUp() self.plot = PlotWindow() self.widget = MaskToolsWidget.MaskToolsDockWidget(plot=self.plot, name='TEST') self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, self.widget) self.plot.show() self.qWaitForWindowExposed(self.plot) self.maskWidget = self.widget.widget()
def setUp(self): super(TestProfileToolBar, self).setUp() self.plot = PlotWindow() self.toolBar = Profile.ProfileToolBar(plot=self.plot) self.plot.addToolBar(self.toolBar) self.plot.show() self.qWaitForWindowExposed(self.plot) self.mouseMove(self.plot) # Move to center self.qapp.processEvents() deprecation.FORCE = True
def __init__(self, *args): super(PlotWidget, self).__init__( logScale=False, grid=True, yInverted=False, roi=False, mask=False, print_=False, backend=BackendMatplotlibQt) self.setActiveCurveHandling(False) self.setGraphGrid('both') profileWindow = PlotWindow( logScale=False, grid=True, yInverted=False, roi=False, mask=False, print_=False) profileWindow.setWindowTitle('') self.profile = ProfileToolBar(plot=self, profileWindow=profileWindow) self.addToolBar(self.profile)
def setUp(self): super(TestCurveLegendsWidget, self).setUp() self.plot = PlotWindow() self.legends = CurveLegendsWidget.CurveLegendsWidget() self.legends.setPlotWidget(self.plot) dock = qt.QDockWidget() dock.setWindowTitle('Curve Legends') dock.setWidget(self.legends) self.plot.addTabbedDockWidget(dock) self.plot.show() self.qWaitForWindowExposed(self.plot)
def build(self,comments, height): a = [] for key in Elements.Material.keys(): a.append(key) a.sort() if self.__toolMode: layout = qt.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) else: layout = qt.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.__hboxMaterialCombo = qt.QWidget(self) hbox = self.__hboxMaterialCombo hboxlayout = qt.QHBoxLayout(hbox) hboxlayout.setContentsMargins(0, 0, 0, 0) hboxlayout.setSpacing(0) label = qt.QLabel(hbox) label.setText("Enter name of material to be defined:") self.matCombo = MaterialComboBox(hbox,options=a) hboxlayout.addWidget(label) hboxlayout.addWidget(self.matCombo) layout.addWidget(hbox) #self.matCombo.setEditable(True) self.matCombo.sigMaterialComboBoxSignal.connect( \ self._comboSlot) self.materialGUI = MaterialGUI(self, comments=comments, height=height, toolmode=self.__toolMode) self.materialGUI.sigMaterialTransmissionSignal.connect( \ self._transmissionSlot) self.materialGUI.sigMaterialMassAttenuationSignal.connect( \ self._massAttenuationSlot) if self.__toolMode: self.materialGUI.setCurrent(a[0]) if (self.graph is None): self.graph = PlotWindow(self, control=True, position=True, colormap=False, aspectRatio=False, yInverted=False, roi=False, mask=False) self.graph.setDefaultPlotPoints(True) layout.addWidget(self.materialGUI) layout.addWidget(self.graph) else: self.materialGUI.setCurrent(a[0]) layout.addWidget(self.materialGUI)
def plot_histo(self, x, y, progressBarValue, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle="", log_x=False, log_y=False, color='blue', replace=True, control=False): if self.plot_canvas[plot_canvas_index] is None: self.plot_canvas[plot_canvas_index] = PlotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=control, position=True, roi=False, mask=False, fit=False) self.plot_canvas[plot_canvas_index].setDefaultPlotLines(True) self.plot_canvas[plot_canvas_index].setActiveCurveColor(color="#00008B") self.plot_canvas[plot_canvas_index].setGraphXLabel(xtitle) self.plot_canvas[plot_canvas_index].setGraphYLabel(ytitle) self.tab[tabs_canvas_index].layout().addWidget(self.plot_canvas[plot_canvas_index]) XoppyPlot.plot_histo(self.plot_canvas[plot_canvas_index], x, y, title, xtitle, ytitle, color, replace) self.plot_canvas[plot_canvas_index].setXAxisLogarithmic(log_x) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(log_y) if min(y) < 0: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y)*1.2, max(y)*1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y)*1.01, max(y)*1.01) else: if log_y: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y), max(y)*1.2) else: self.plot_canvas[plot_canvas_index].setGraphYLimits(min(y), max(y)*1.01) self.progressBarSet(progressBarValue)
def __init__(self, parent, spectrum, energy=None): qt.QWidget.__init__(self, parent) self.setWindowTitle("XAS Normalization Configuration Window") self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(2) if energy is None: self.energy = range(len(spectrum)) else: self.energy = energy self.spectrum = spectrum self.parametersWidget = XASNormalizationParametersWidget(self) self.graph = PlotWindow(self, position=False, aspectRatio=False, colormap=False, yInverted=False, roi=False, mask=False, fit=False) # next two lines deprecated with silx 0.8.0 # self.graph.zoomModeAction.setVisible(False) # self.graph.panModeAction.setVisible(False) toolbar = self.graph.getInteractiveModeToolBar() toolbar.getZoomModeAction().setVisible(False) toolbar.getPanModeAction().setVisible(False) self.__lastDict = {} self.graph.sigPlotSignal.connect(self._handleGraphSignal) self.graph.addCurve(self.energy, spectrum, legend="Spectrum") self.graph.setActiveCurve("Spectrum") self.mainLayout.addWidget(self.parametersWidget) self.mainLayout.addWidget(self.graph) # initialize variables edgeEnergy, sortedX, sortedY, xPrime, yPrime =\ XASNormalization.estimateXANESEdge(spectrum, energy=self.energy, full=True) self._xPrime = xPrime self._yPrime = yPrime self.parametersWidget.setEdgeEnergy(edgeEnergy, emin=self.energy.min(), emax=self.energy.max()) self.getParameters = self.parametersWidget.getParameters self.setParameters = self.parametersWidget.setParameters self.parametersWidget.sigXASNormalizationParametersSignal.connect( \ self.updateGraph) self.updateGraph(self.getParameters())
def plot_data1D(self, dataX, dataY, tabs_canvas_index, plot_canvas_index, title="", xtitle="", ytitle=""): self.tab[tabs_canvas_index].layout().removeItem(self.tab[tabs_canvas_index].layout().itemAt(0)) self.plot_canvas[plot_canvas_index] = PlotWindow() self.plot_canvas[plot_canvas_index].addCurve(dataX, dataY,) 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].setXAxisLogarithmic(False) self.plot_canvas[plot_canvas_index].setYAxisLogarithmic(False) 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])
def setUp(self): TestCaseQt.setUp(self) # define plot self.plot = PlotWindow() self.plot.addImage(numpy.arange(10000).reshape(100, 100), legend='img1') self.img_item = self.plot.getImage('img1') self.plot.addCurve(x=numpy.linspace(0, 10, 56), y=numpy.arange(56), legend='curve1') self.curve_item = self.plot.getCurve('curve1') self.plot.addHistogram(edges=numpy.linspace(0, 10, 56), histogram=numpy.arange(56), legend='histo1') self.histogram_item = self.plot.getHistogram(legend='histo1') self.plot.addScatter(x=numpy.linspace(0, 10, 56), y=numpy.linspace(0, 10, 56), value=numpy.arange(56), legend='scatter1') self.scatter_item = self.plot.getScatter(legend='scatter1') # stats widget self.statsWidget = ROIStatsWidget(plot=self.plot) # define stats stats = [ ('sum', numpy.sum), ('mean', numpy.mean), ] self.statsWidget.setStats(stats=stats) # define rois self.roi1D = ROI(name='range1', fromdata=0, todata=4, type_='energy') self.rectangle_roi = RectangleROI() self.rectangle_roi.setGeometry(origin=(0, 0), size=(20, 20)) self.rectangle_roi.setName('Initial ROI') self.polygon_roi = PolygonROI() points = numpy.array([[0, 5], [5, 0], [10, 5], [5, 10]]) self.polygon_roi.setPoints(points)
def __init__(self, parent=None, backend=None): super(RateLawMdiArea, self).__init__(parent) self._windowDict = {} self._windowList = ["Original", "Zero", "First", "Second"] self._windowList.reverse() for title in self._windowList: plot = PlotWindow(self, position=True, backend=backend, colormap=False, aspectRatio=False, yInverted=False, roi=False, mask=False) self.pluginsToolButton = PluginsToolButton(plot=plot) plot.toolBar().addWidget(self.pluginsToolButton) plot.setWindowTitle(title) self.addSubWindow(plot) self._windowDict[title] = plot plot.setDataMargins(0, 0, 0.025, 0.025) self._windowList.reverse() self.setActivationOrder(qt.QMdiArea.StackingOrder) self.tileSubWindows()
def setUp(self): super(TestPlotWindow, self).setUp() self.plot = PlotWindow() self.plot.show() self.qWaitForWindowExposed(self.plot)
def _createPlot(self): return PlotWindow()
def plot_array(ar, title, xlabel, ylabel): window = PlotWindow(fit=True) window.setGraphTitle(title) window.addCurve(ar[:, 0], ar[:, 1], xlabel=xlabel, ylabel=ylabel) window.show()
def __init__(self, parent=None, fit=None, graph=None, actions=True): qt.QWidget.__init__(self, parent) self.setWindowTitle("SimpleFitGui") if fit is None: self.fitModule = SimpleFitModule.SimpleFit() self.fitModule.importFunctions(SimpleFitUserEstimatedFunctions) self.fitModule.loadUserFunctions() else: self.fitModule = fit if graph is None: self.__useTab = True self.graph = PlotWindow(self, aspectRatio=False, colormap=False, yInverted=False, roi=False, mask=False, fit=False, control=True, position=True) self.graph.getInteractiveModeToolBar().setVisible(False) # No context menu by default, execute zoomBack on right click plotArea = self.graph.getWidgetHandle() plotArea.setContextMenuPolicy(qt.Qt.CustomContextMenu) plotArea.customContextMenuRequested.connect(self._zoomBack) else: self.__useTab = False self.graph = graph self._configurationDialog = None self.mainLayout = qt.QVBoxLayout(self) self.mainLayout.setContentsMargins(2, 2, 2, 2) self.mainLayout.setSpacing(2) self.topWidget = TopWidget(self) config = self.fitModule.getConfiguration() self.topWidget.setFunctions(config['fit']['functions']) config = None if self.__useTab: self.mainTab = qt.QTabWidget(self) self.mainLayout.addWidget(self.mainTab) self.parametersTable = Parameters.Parameters() self.mainTab.addTab(self.graph, 'GRAPH') self.mainTab.addTab(self.parametersTable, 'FIT') else: self.parametersTable = Parameters.Parameters(self) self.statusWidget = StatusWidget(self) self.mainLayout.addWidget(self.topWidget) if self.__useTab: self.mainLayout.addWidget(self.mainTab) else: self.mainLayout.addWidget(self.parametersTable) self.mainLayout.addWidget(self.statusWidget) if actions: #build the actions widget self.fitActions = qt.QWidget(self) self.fitActions.mainLayout = qt.QHBoxLayout(self.fitActions) self.fitActions.mainLayout.setContentsMargins(2, 2, 2, 2) self.fitActions.mainLayout.setSpacing(2) self.fitActions.estimateButton = qt.QPushButton(self.fitActions) self.fitActions.estimateButton.setText("Estimate") self.fitActions.startFitButton = qt.QPushButton(self.fitActions) self.fitActions.startFitButton.setText("Start Fit") self.fitActions.dismissButton = qt.QPushButton(self.fitActions) self.fitActions.dismissButton.setText("Dismiss") self.fitActions.mainLayout.addWidget( self.fitActions.estimateButton) self.fitActions.mainLayout.addWidget( self.fitActions.startFitButton) self.fitActions.mainLayout.addWidget(self.fitActions.dismissButton) self.mainLayout.addWidget(self.fitActions) #connect top widget self.topWidget.addFunctionButton.clicked.connect(\ self.importFunctions) self.topWidget.fitFunctionCombo.currentIndexChanged[int].connect(\ self.fitFunctionComboSlot) self.topWidget.backgroundCombo.currentIndexChanged[int].connect(\ self.backgroundComboSlot) self.topWidget.configureButton.clicked.connect(\ self.configureButtonSlot) if actions: #connect actions self.fitActions.estimateButton.clicked.connect(self.estimate) self.fitActions.startFitButton.clicked.connect(self.startFit) self.fitActions.dismissButton.clicked.connect(self.dismiss)
def createWidget(self, parent): plot = PlotWindow(parent) plot.setAutoReplot(False) return plot
def do_plot(self): old_tab_index = self.tabs.currentIndex() try: for i in range(len(self.tab_titles)): self.tab[i].layout().removeItem(self.tab[i].layout().itemAt(0)) except: pass if self.INDIVIDUAL_MODES: self.tab_titles = [ "SPECTRUM", "CUMULATED SPECTRUM", "SPECTRAL DENSITY (INTENSITY)", "SPECTRAL INTENSITY FROM MODES", "REFERENCE ELECRON DENSITY", "REFERENCE UNDULATOR WAVEFRONT", "INDIVIDUAL MODES", ] else: self.tab_titles = [ "SPECTRUM", "CUMULATED SPECTRUM", "SPECTRAL DENSITY (INTENSITY)", "REFERENCE ELECRON DENSITY", "REFERENCE UNDULATOR WAVEFRONT", "MODE INDEX: %d" % self.MODE_INDEX, ] self.initialize_tabs() if self.TYPE_PRESENTATION == 0: myprocess = self._square_modulus title0 = "Intensity of eigenvalues" title1 = "Intensity of eigenvector" if self.TYPE_PRESENTATION == 1: myprocess = numpy.absolute title0 = "Modulus of eigenvalues" title1 = "Modulus of eigenvector" elif self.TYPE_PRESENTATION == 2: myprocess = numpy.real title0 = "Real part of eigenvalues" title1 = "Real part of eigenvector" elif self.TYPE_PRESENTATION == 3: myprocess = numpy.imag title0 = "Imaginary part of eigenvalues" title1 = "Imaginary part of eigenvectos" elif self.TYPE_PRESENTATION == 4: myprocess = numpy.angle title0 = "Angle of eigenvalues [rad]" title1 = "Angle of eigenvector [rad]" if self._input_available: x_values = numpy.arange(self.af.number_modes()) x_label = "Mode index" y_label = "Occupation" xx = self.af.x_coordinates() yy = self.af.y_coordinates() xmin = numpy.min(xx) xmax = numpy.max(xx) ymin = numpy.min(yy) ymax = numpy.max(yy) else: raise Exception("Nothing to plot") # # plot spectrum # tab_index = 0 self.plot_canvas[tab_index] = PlotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=False, position=True, roi=False, mask=False, fit=False) self.tab[tab_index].layout().addWidget(self.plot_canvas[tab_index]) self.plot_canvas[tab_index].setDefaultPlotLines(True) self.plot_canvas[tab_index].setXAxisLogarithmic(False) self.plot_canvas[tab_index].setYAxisLogarithmic(False) self.plot_canvas[tab_index].setGraphXLabel(x_label) self.plot_canvas[tab_index].setGraphYLabel(y_label) self.plot_canvas[tab_index].addCurve(x_values, numpy.abs( self.af.occupation_array()), title0, symbol='', xlabel="X", ylabel="Y", replace=False) #'+', '^', ',' self.tab[tab_index].layout().addWidget(self.plot_canvas[tab_index]) # # plot cumulated spectrum # tab_index += 1 self.plot_canvas[tab_index] = PlotWindow(parent=None, backend=None, resetzoom=True, autoScale=False, logScale=True, grid=True, curveStyle=True, colormap=False, aspectRatio=False, yInverted=False, copy=True, save=True, print_=True, control=False, position=True, roi=False, mask=False, fit=False) self.tab[tab_index].layout().addWidget(self.plot_canvas[tab_index]) self.plot_canvas[tab_index].setDefaultPlotLines(True) self.plot_canvas[tab_index].setXAxisLogarithmic(False) self.plot_canvas[tab_index].setYAxisLogarithmic(False) self.plot_canvas[tab_index].setGraphXLabel(x_label) self.plot_canvas[tab_index].setGraphYLabel("Cumulated occupation") self.plot_canvas[tab_index].addCurve( x_values, self.af.cumulated_occupation_array(), "Cumulated occupation", symbol='', xlabel="X", ylabel="Y", replace=False) #'+', '^', ',' self.plot_canvas[tab_index].setGraphYLimits(0.0, 1.0) self.tab[tab_index].layout().addWidget(self.plot_canvas[tab_index]) # # plot spectral density # tab_index += 1 image = myprocess((self.af.spectral_density())) self.plot_data2D(image, 1e6 * self.af.x_coordinates(), 1e6 * self.af.y_coordinates(), tab_index, title="Spectral Density (Intensity)", xtitle="X [um] (%d pixels)" % (image.shape[0]), ytitle="Y [um] (%d pixels)" % (image.shape[1])) # # plot spectral density from modes # if self.INDIVIDUAL_MODES: tab_index += 1 image = myprocess((self.af.intensity_from_modes())) self.plot_data2D(image, 1e6 * self.af.x_coordinates(), 1e6 * self.af.y_coordinates(), tab_index, title="Spectral Density (Intensity)", xtitle="X [um] (%d pixels)" % (image.shape[0]), ytitle="Y [um] (%d pixels)" % (image.shape[1])) # # plot reference electron density # tab_index += 1 image = numpy.abs(self.af.reference_electron_density() )**2 #TODO: Correct? it is complex... self.plot_data2D(image, 1e6 * self.af.x_coordinates(), 1e6 * self.af.y_coordinates(), tab_index, title="Reference electron density", xtitle="X [um] (%d pixels)" % (image.shape[0]), ytitle="Y [um] (%d pixels)" % (image.shape[1])) # # plot reference undulator radiation # tab_index += 1 image = self.af.reference_undulator_radiation()[ 0, :, :, 0] #TODO: Correct? is polarized? self.plot_data2D(image, 1e6 * self.af.x_coordinates(), 1e6 * self.af.y_coordinates(), tab_index, title="Reference undulator radiation", xtitle="X [um] (%d pixels)" % (image.shape[0]), ytitle="Y [um] (%d pixels)" % (image.shape[1])) # # plot all modes # if self.INDIVIDUAL_MODES: tab_index += 1 dim0_calib = (0, 1) dim1_calib = (1e6 * yy[0], 1e6 * (yy[1] - yy[0])) dim2_calib = (1e6 * xx[0], 1e6 * (xx[1] - xx[0])) colormap = { "name": "temperature", "normalization": "linear", "autoscale": True, "vmin": 0, "vmax": 0, "colors": 256 } self.plot_canvas[tab_index] = StackViewMainWindow() self.plot_canvas[tab_index].setGraphTitle(title1) self.plot_canvas[tab_index].setLabels([ "Mode number", "Y index from %4.2f to %4.2f um" % (1e6 * ymin, 1e6 * ymax), "X index from %4.2f to %4.2f um" % (1e6 * xmin, 1e6 * xmax), ]) self.plot_canvas[tab_index].setColormap(colormap=colormap) self.plot_canvas[tab_index].setStack( myprocess(numpy.swapaxes(self.af.modes(), 2, 1)), calibrations=[dim0_calib, dim1_calib, dim2_calib]) self.tab[tab_index].layout().addWidget(self.plot_canvas[tab_index]) else: tab_index += 1 image = myprocess((self.af.mode(self.MODE_INDEX))) self.plot_data2D(image, 1e6 * self.af.x_coordinates(), 1e6 * self.af.y_coordinates(), tab_index, title="Mode %d" % self.MODE_INDEX, xtitle="X [um] (%d pixels)" % (image.shape[0]), ytitle="Y [um] (%d pixels)" % (image.shape[1])) # try: self.tabs.setCurrentIndex(old_tab_index) except: pass
# and assign the result to a new array y1 # (do not modify y0 if you want to preserve the original curve) y1 = y0 + 1.0 # Re-using the same legend causes the original curve # to be replaced self.plot.addCurve(x0, y1, legend=legend, info=info) # creating QApplication is mandatory in order to use qt widget app = qt.QApplication([]) sys.excepthook = qt.exceptionHandler # create a PlotWindow plotwin = PlotWindow() # Add a new toolbar toolbar = qt.QToolBar("My toolbar") plotwin.addToolBar(toolbar) # Get a reference to the PlotWindow's menu bar, add a menu menubar = plotwin.menuBar() actions_menu = menubar.addMenu("Custom actions") # Initialize our action, give it plotwin as a parameter myaction = ShiftUpAction(plotwin) # Add action to the menubar and toolbar toolbar.addAction(myaction) actions_menu.addAction(myaction) # Plot a couple of curves with synthetic data x = [0, 1, 2, 3, 4, 5, 6]
# remove restored data from info dict for key in ["complex fft", "original x"]: del info[key] # plot the original data self.plot.addCurve(x1, y1, legend=legend1, info=info) self.plot.resetZoom() app = qt.QApplication([]) sys.excepthook = qt.exceptionHandler plotwin = PlotWindow(control=True) toolbar = qt.QToolBar("My toolbar") plotwin.addToolBar(toolbar) myaction = FftAction(plotwin) toolbar.addAction(myaction) # x range: 0 -- 10 (1000 points) x = numpy.arange(1000) * 0.01 twopi = 2 * numpy.pi # Sum of sine functions with frequencies 3, 20 and 42 Hz y1 = numpy.sin(twopi * 3 * x) + 1.5 * numpy.sin( twopi * 20 * x) + 2 * numpy.sin(twopi * 42 * x) # Cosine with frequency 7 Hz and phase pi / 3 y2 = numpy.cos(twopi * 7 * (x - numpy.pi / 3))