def initialize(self): self.colors = [ QtGui.QColor(255, 0, 0), QtGui.QColor(50, 50, 50), QtGui.QColor(255, 0, 255), QtGui.QColor(0, 200, 100), QtGui.QColor(0, 0, 255), QtGui.QColor(255, 0, 80), QtGui.QColor(100, 0, 80), QtGui.QColor(100, 0, 0) ] self.curves = [] self.ranges = [] self.setCanvasBackground(Qt.Qt.white) picker_on = Qwt.QwtPicker.AlwaysOn picker_on = Qwt.QwtPicker.AlwaysOff self.zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.DragSelection, picker_on, self.canvas()) self.zoomer.setRubberBandPen(QtGui.QPen(Qt.Qt.black)) self.zoomer.setTrackerPen(QtGui.QPen(Qt.Qt.black)) self.panner = Qwt.QwtPlotPanner(self.canvas()) self.panner.setMouseButton(Qt.Qt.MidButton)
def __init__(self, parent=None): Qwt.QwtPlot.__init__(self, parent) self.__spectrogram = Qwt.QwtPlotSpectrogram() self.zoomer = Qwt.QwtPlotZoomer(self.canvas()) self.zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect2, Qt.Qt.RightButton, Qt.Qt.ControlModifier) self.zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect3, Qt.Qt.RightButton) self.zoomer.setRubberBandPen(Qt.Qt.darkBlue) self.zoomer.setTrackerPen(Qt.Qt.darkBlue) xmin = -10 ymin = -10 xmax = 10 ymax = 10 x_a = [] y_a = [] intes = [] for x in np.linspace(xmin, xmax, 50): for y in np.linspace(ymin, ymax, 50): x_a.append(x) y_a.append(y) # I just used a random function from https://www.physicsforums.com/threads/cool-3-d-functions-for-graphing.140087/ to display # intes.append(x+y) # This is the actual function I used for testing. It is much simplier and you can tell where every point should be intes.append(max([-2*(round(math.e**(-(x*2)**2)) + round(math.e**(-(y*2)**2)))+ 2+2*math.cos((x**2+y**2)/4), 25*math.e**(-1*(x**2+y**2)*3)])) # # x_a = sorted(x_a, reverse= True) # y_a = sorted(y_a, reverse=True) intes = np.asarray(intes) rightAxis = self.axisWidget(Qwt.QwtPlot.yRight) rightAxis.setTitle("Intensity") rightAxis.setColorBarEnabled(True) rightAxis.setColorMap(self.__spectrogram.data().range(), self.__spectrogram.colorMap()) self.enableAxis(Qwt.QwtPlot.yRight) # LeftButton for the zooming # MidButton for the panning # RightButton: zoom out by 1 # Ctrl+RighButton: zoom out to full size # panner = Qwt.QwtPlotPanner(self.canvas()) panner.setAxisEnabled(Qwt.QwtPlot.yRight, False) panner.setMouseButton(Qt.Qt.MidButton) # Avoid jumping when labels with more/less digits # appear/disappear when scrolling vertically # fm = Qt.QFontMetrics(self.axisWidget(Qwt.QwtPlot.yLeft).font()) self.axisScaleDraw( Qwt.QwtPlot.yLeft).setMinimumExtent(fm.width("100.00"))
def __init__(self, parent=None): Qwt.QwtPlot.__init__(self, parent) self.__spectrogram = Qwt.QwtPlotSpectrogram() colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) colorMap.addColorStop(0.1, Qt.Qt.cyan) colorMap.addColorStop(0.6, Qt.Qt.green) colorMap.addColorStop(0.95, Qt.Qt.yellow) self.__spectrogram.setColorMap(colorMap) self.__spectrogram.setData(SpectrogramData()) self.__spectrogram.attach(self) self.__spectrogram.setContourLevels( [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]) rightAxis = self.axisWidget(Qwt.QwtPlot.yRight) rightAxis.setTitle("Intensity") rightAxis.setColorBarEnabled(True) rightAxis.setColorMap(self.__spectrogram.data().range(), self.__spectrogram.colorMap()) self.setAxisScale(Qwt.QwtPlot.yRight, self.__spectrogram.data().range().minValue(), self.__spectrogram.data().range().maxValue()) self.enableAxis(Qwt.QwtPlot.yRight) self.plotLayout().setAlignCanvasToScales(True) self.replot() # LeftButton for the zooming # MidButton for the panning # RightButton: zoom out by 1 # Ctrl+RighButton: zoom out to full size zoomer = Qwt.QwtPlotZoomer(self.canvas()) zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect2, Qt.Qt.RightButton, Qt.Qt.ControlModifier) zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect3, Qt.Qt.RightButton) zoomer.setRubberBandPen(Qt.Qt.darkBlue) zoomer.setTrackerPen(Qt.Qt.darkBlue) panner = Qwt.QwtPlotPanner(self.canvas()) panner.setAxisEnabled(Qwt.QwtPlot.yRight, False) panner.setMouseButton(Qt.Qt.MidButton) # Avoid jumping when labels with more/less digits # appear/disappear when scrolling vertically fm = Qt.QFontMetrics(self.axisWidget(Qwt.QwtPlot.yLeft).font()) self.axisScaleDraw(Qwt.QwtPlot.yLeft).setMinimumExtent( fm.width("100.00"))
def makeplot(self): '''set up plotting''' # make any contents fill the empty frame self.ui.axes.setLayout(QtGui.QGridLayout(self.ui.axes)) # Draw a plot in the frame. We do this, rather than defining the # QwtPlot object in Qt designer because loadUi then fails! plot = Qwt5.QwtPlot(self.ui.axes) self.ui.axes.layout().addWidget(plot) self.plot = plot self.cx = self.makecurve(X_colour) self.cy = self.makecurve(Y_colour) # set background to black plot.setCanvasBackground(QtCore.Qt.black) # Enable zooming plot.setStatusTip(self.Plot_tooltip) zoom = Qwt5.QwtPlotZoomer(plot.canvas()) zoom.setRubberBandPen(QtGui.QPen(QtCore.Qt.white)) zoom.setTrackerPen(QtGui.QPen(QtCore.Qt.white)) # This is a poorly documented trick to disable the use of the right # button for cancelling zoom, so we can use it for panning instead. The # first argument of setMousePattern() selects the zooming action, and is # one of the following with the given default assignment: # # Index Button Action # 0 Left Mouse Start and stop rubber band selection # 1 Right Mouse Restore to original unzoomed axes # 2 Middle Mouse Zoom out one level # 3 Shift Left ? # 4 Shift Right ? # 5 Shift Middle Zoom back in one level zoom.setMousePattern(1, QtCore.Qt.NoButton) self.zoom = zoom # Enable panning. We reconfigure the active mouse to use the right # button so that panning and zooming can coexist. pan = Qwt5.QwtPlotPanner(plot.canvas()) pan.setMouseButton(QtCore.Qt.RightButton) # Monitor mouse movements over the plot area so we can show the position # in coordinates. SpyMouse(plot.canvas()).MouseMove.connect(self.mouse_move)
def __init__(self, *args, **kwargs): self.monitor = kwargs['monitor'] del kwargs['monitor'] self.VAR = kwargs['VAR'] del kwargs['VAR'] Qwt.QwtPlot.__init__(self, *args) self.contour = True self.__spectrogram = Qwt.QwtPlotSpectrogram() # LeftButton for the zooming # MidButton for the panning # RightButton: zoom out by 1 # Ctrl+RighButton: zoom out to full size self.zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.DragSelection, Qwt.QwtPicker.AlwaysOn, self.canvas()) self.zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect2, Qt.Qt.RightButton, Qt.Qt.ControlModifier) self.zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect3, Qt.Qt.RightButton) self.zoomer.setRubberBandPen(Qt.Qt.darkBlue) self.zoomer.setTrackerPen(Qt.Qt.darkBlue) if not hasattr(self, 'log'): self.log = False xmin = -10 ymin = -10 xmax = 10 ymax = 10 x_a = [] y_a = [] intes = [] for x in np.linspace(xmin, xmax, 50): for y in np.linspace(ymin, ymax, 50): x_a.append(x) y_a.append( y ) # I just used a random function from https://www.physicsforums.com/threads/cool-3-d-functions-for-graphing.140087/ to display # intes.append(x+y) # This is the actual function I used for testing. It is much simplier and you can tell where every point should be intes.append( max([ -2 * (round(math.e**(-(x * 2)**2)) + round(math.e** (-(y * 2)**2))) + 2 + 2 * math.cos((x**2 + y**2) / 4), 25 * math.e**(-1 * (x**2 + y**2) * 3) ])) self.plot(x_a, y_a, intes) panner = Qwt.QwtPlotPanner(self.canvas()) panner.setAxisEnabled(Qwt.QwtPlot.yRight, False) panner.setMouseButton(Qt.Qt.MidButton) # Avoid jumping when labels with more/less digits # appear/disappear when scrolling vertically # fm = Qt.QFontMetrics(self.axisWidget(Qwt.QwtPlot.yLeft).font()) self.axisScaleDraw(Qwt.QwtPlot.yLeft).setMinimumExtent( fm.width("100.00"))