def _simulateAndPlot(self, key): key = str(key) equationText = self.demo.getEquation(key).replace('\n', '<br/>') doc = IzhikevichDemo.documentation[key].replace('\n', '<br/>') text = '<b>%s:</b> %s<p><b>Equation:</b><br/> %s' % (key, doc, equationText) self.descriptionWidget.setText(self.tr(text)) # if key == 'accommodation': # mbox = QtGui.QMessageBox(self) # mbox.setText(self.tr('Accommodation cannot be shown with regular Izhikevich model.')) # mbox.setDetailedText(self.tr('\ # Equation for u for the accommodating neuron is: \ # u\' = a * b * (V + 65)\n Which is different from \ # the regular equation u\' = a * (b*V - u) and cannot \ # be obtained from the latter by any choice of a and b.')) # mbox.show() # return (time, Vm, Im) = self.demo.simulate(key) Vm = numpy.array(Vm.vector) * 1e3 Im = numpy.array(Im.vector) * 1e9 self.VmPlot.clear() self.ImPlot.clear() curve = Qwt.QwtPlotCurve(self.tr(key + '_Vm')) curve.setPen(QtCore.Qt.red) curve.setData(time, numpy.array(Vm)) curve.attach(self.VmPlot) curve = Qwt.QwtPlotCurve(self.tr(key + '_Im')) curve.setPen(QtCore.Qt.blue) curve.setData(time, Im) curve.attach(self.ImPlot) self.imPlotZoomer.setZoomBase() self.vmPlotZoomer.setZoomBase() self.ImPlot.replot() self.VmPlot.replot()
def doPlot(self, data, data_mean, means): if self.plotRealtime: xaxis = np.arange(0,len(data)) curve1 = Qwt5.QwtPlotCurve('') curve2 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.black) pen.setStyle(QtCore.Qt.SolidLine) curve1.setPen(pen) curve1.attach(self._ui.qwtPlot) curve1.setData(xaxis,data) pen = QtGui.QPen(QtCore.Qt.red) pen.setStyle(QtCore.Qt.SolidLine) curve2.setPen(pen) curve2.attach(self._ui.qwtPlot) curve2.setData(np.array([xaxis[0],xaxis[-1]]), np.array([data_mean, data_mean])) self._ui.qwtPlot.replot() curve1.detach() curve2.detach() else: xaxis = np.arange(0,len(means)) curve1 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.black) pen.setStyle(QtCore.Qt.SolidLine) curve1.setPen(pen) curve1.attach(self._ui.qwtPlot) curve1.setData(xaxis,means) self._ui.qwtPlot.replot() curve1.detach()
def addCurve(self, frequency_axis, transfer_function, vertical_units): transfer_function_uncalibrated = copy.copy(transfer_function) * ( 10**((-5.06 - -6. + 0.16) / 20.) ) # adjustment based on low-frequency RedPitaya's transfer function self.writeOutputFile( transfer_function_uncalibrated, frequency_axis, vertical_units, bCalibrated=False ) # we always save the uncalibrated TF regardless of whether we apply cal or not # Load and apply calibration data based on the measurement of the Red Pitaya's transfer function: if vertical_units == 'V/V': # the copy.copy() is not strictly needed since applying the calibration would create a copy, but this potentially avoids a mistake later if I bypass the calibration transfer_function_calibrated = self.loadAndApplyCalibration( transfer_function_uncalibrated, frequency_axis) self.transfer_function_list.append(transfer_function_calibrated) self.writeOutputFile(transfer_function_calibrated, frequency_axis, vertical_units, bCalibrated=True) else: self.transfer_function_list.append(transfer_function_uncalibrated) self.vertical_units_list.append(copy.copy(vertical_units)) self.frequency_axis_list.append(copy.copy(frequency_axis)) # create a new curve object in both magnitude and phase plots: # magnitude plot #TODO: add color cycling according to matlab's color scheme. current_color_as_list = self.colors_order[ (len(self.transfer_function_list) - 1) % len(self.colors_order)] R_value = current_color_as_list[0] G_value = current_color_as_list[1] B_value = current_color_as_list[2] current_color = Qt.QColor(R_value, G_value, B_value) self.curve_mag_list.append(Qwt.QwtPlotCurve('qplt_freq')) self.curve_mag_list[-1].attach(self.qplt_mag) self.curve_mag_list[-1].setPen(Qt.QPen(current_color)) self.curve_mag_list[-1].setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(current_color), Qt.QPen(current_color), Qt.QSize(3, 3))) self.curve_mag_list[-1].setRenderHint( Qwt.QwtPlotItem.RenderAntialiased) # Create the curve in the phase plot self.curve_phase_list.append(Qwt.QwtPlotCurve('qplt_freq')) self.curve_phase_list[-1].attach(self.qplt_phase) self.curve_phase_list[-1].setPen(Qt.QPen(current_color)) self.curve_phase_list[-1].setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(current_color), Qt.QPen(current_color), Qt.QSize(3, 3))) self.curve_phase_list[-1].setRenderHint( Qwt.QwtPlotItem.RenderAntialiased) self.updateGraph() return
def __init__(self, *args): Qt.QFrame.__init__(self, *args) self.setFrameStyle(Qt.QFrame.Box | Qt.QFrame.Raised) self.setLineWidth(2) self.setMidLineWidth(3) p = Qt.QPalette() p.setColor(self.backgroundRole(), Qt.QColor(30, 30, 50)) self.setPalette(p) # make curves and maps self.tuples = [] # curve 1 curve = Qwt.QwtPlotCurve() curve.setPen(Qt.QPen(Qt.QColor(150, 150, 200), 2)) curve.setStyle(Qwt.QwtPlotCurve.Spline) curve.setCurveAttribute(Qwt.QwtPlotCurve.Xfy) curve.setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, Qt.QBrush(), Qt.QPen(Qt.Qt.yellow, 2), Qt.QSize(7, 7))) self.tuples.append((curve, Qwt.QwtScaleMap(0, 100, -1.5, 1.5), Qwt.QwtScaleMap(0, 100, 0.0, 2 * pi))) # curve 2 curve = Qwt.QwtPlotCurve() curve.setPen(Qt.QPen(Qt.QColor(200, 150, 50), 1, Qt.Qt.DashDotDotLine)) curve.setStyle(Qwt.QwtPlotCurve.Sticks) curve.setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.blue), Qt.QPen(Qt.Qt.yellow), Qt.QSize(5, 5))) self.tuples.append((curve, Qwt.QwtScaleMap(0, 100, 0.0, 2 * pi), Qwt.QwtScaleMap(0, 100, -3.0, 1.1))) # curve 3 curve = Qwt.QwtPlotCurve() curve.setPen(Qt.QPen(Qt.QColor(100, 200, 150))) curve.setStyle(Qwt.QwtPlotCurve.Spline) curve.setCurveAttribute(Qwt.QwtPlotCurve.Periodic) curve.setCurveAttribute(Qwt.QwtPlotCurve.Parametric) curve.setSplineSize(200) self.tuples.append( (curve, Qwt.QwtScaleMap(0, 100, -1.1, 3.0), Qwt.QwtScaleMap(0, 100, -1.1, 3.0))) # curve 4 curve = Qwt.QwtPlotCurve() curve.setPen(Qt.QPen(Qt.Qt.red)) curve.setStyle(Qwt.QwtPlotCurve.Spline) curve.setSplineSize(200) self.tuples.append( (curve, Qwt.QwtScaleMap(0, 100, -5.0, 1.1), Qwt.QwtScaleMap(0, 100, -1.1, 5.0))) # data self.phase = 0.0 self.base = arange(0.0, 2.01 * pi, 2 * pi / (USize - 1)) self.uval = cos(self.base) self.vval = sin(self.base) self.uval[1::2] *= 0.5 self.vval[1::2] *= 0.5 self.newValues() # start timer self.tid = self.startTimer(250)
def __init__(self,regs=None): QtGui.QWidget.__init__(self) self.setGeometry(300, 300, 1000, 600) self.setWindowTitle('qgui') self.fig1=Qwt5.QwtPlot() self.fig1.setParent(self) self.fig1.setGeometry(300,0,400,300) self.fig2=Qwt5.QwtPlot() self.fig2.setParent(self) self.fig2.setGeometry(300,300,400,300) self.curves1=[] self.curves2=[] pens=[QtCore.Qt.red, QtCore.Qt.black, QtCore.Qt.cyan, QtCore.Qt.darkCyan, QtCore.Qt.darkRed, QtCore.Qt.magenta, QtCore.Qt.darkMagenta, QtCore.Qt.green, QtCore.Qt.darkGreen, QtCore.Qt.yellow, QtCore.Qt.darkYellow, QtCore.Qt.blue, QtCore.Qt.darkBlue, QtCore.Qt.gray, QtCore.Qt.darkGray, QtCore.Qt.lightGray] for index in range(16): #up to 16 curves here self.curves1.append(Qwt5.QwtPlotCurve()) self.curves1[index].attach(self.fig1) self.curves1[index].setPen(QtGui.QPen(pens[index])) self.curves2.append(Qwt5.QwtPlotCurve()) self.curves2[index].attach(self.fig2) self.curves2[index].setPen(QtGui.QPen(pens[index])) self.layout = QtGui.QVBoxLayout(self) self.layout.setContentsMargins(0,0,0,0) self.layout.setSpacing(0) self.slider={} self.param={} index=0 for reg in regs: self.slider[index]=param_slider(self,name=reg.name,process=self.test1,y0=index*30,init=reg.value,s_min=reg.min_value,s_max=reg.max_value) self.param[reg.name]=reg.value #self.slider[index].connect(self.test1) #print self.slider[index],index #self.layout.addWidget(self.slider[index]) index=index+1 print self.param self.socket = eth_test.setup_sock() write=write_thread(self.param,self.socket)#self.sender().addr,self.sender().value) write.start() self.read=read_and_plot_thread(self.socket) self.read.signal_got_new_data.connect(self.replot) self.read.start()
def __init__(self, *args): super(Chart, self).__init__(*args) #set title self.setTitle(u'<h4><font color=red>图表</font></h4>') #背景色 self.setCanvasBackground(Qt.Qt.white) #插入图例--曲线名 self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend) # a variation on the C++ example self.plotLayout().setAlignCanvasToScales(True) #创建网格 grid = Qwt.QwtPlotGrid() grid.setPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine)) grid.attach(self) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, u'Time(s)') self.setAxisTitle(Qwt.QwtPlot.yLeft, u'Values') # set Scale Range self.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 10000.0) self.setAxisScale(Qwt.QwtPlot.yLeft, -10.0, 10.0) # insert a few curves self.curveA = Qwt.QwtPlotCurve(u'curveA') self.curveA.setPen(Qt.QPen(Qt.Qt.red)) self.curveA.attach(self) self.curveB = Qwt.QwtPlotCurve(u'curveB') self.curveB.setPen(Qt.QPen(Qt.Qt.blue)) self.curveB.attach(self) # insert a horizontal marker at y = xxx mY = Qwt.QwtPlotMarker() mY.setLabel(Qwt.QwtText('Maker:Y')) mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mY.setLineStyle(Qwt.QwtPlotMarker.HLine) mY.setYValue(0.0) mY.setLinePen(Qt.QPen(Qt.Qt.green, 1, Qt.Qt.DashDotLine)) mY.attach(self) # insert a vertical marker mX = Qwt.QwtPlotMarker() mX.setLabel(Qwt.QwtText('Maker:X')) mX.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mX.setLineStyle(Qwt.QwtPlotMarker.VLine) mX.setXValue(5000) mX.setLinePen(Qt.QPen(Qt.Qt.green, 1, Qt.Qt.DashDotLine)) mX.attach(self) #Initialize data self.x = np.arange(0.0, 10001.0, 1.0) self.curveAData = np.array([0], np.float) self.curveBData = np.array([0], np.float)
def plotModels(self): if self._ui.plotFit_checkBox.isChecked(): xmodel, sumx = self._control.returnModels() if len(xmodel) > 0: xaxis = np.arange(0, len(xmodel)) curve1 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.black) pen.setStyle(QtCore.Qt.SolidLine) curve1.setPen(pen) curve1.attach(self._ui.qwtPlot) curve1.setData(xaxis, xmodel) curve2 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.blue) pen.setStyle(QtCore.Qt.SolidLine) curve2.setPen(pen) curve2.attach(self._ui.qwtPlot) curve2.setData(xaxis, sumx) self._ui.qwtPlot.replot() curve1.detach() curve2.detach() else: beginFrames = self._control.initialFrames + self._control.unactive_until + 1 if len(self._control.stage_zs) > beginFrames: times1 = np.array(self._control.times) - self._control.times[0] times2 = np.array( self._control.times2) - self._control.times2[0] ts0 = self._control.target_signal[self._control. unactive_until:beginFrames] targetsig = np.mean(ts0) sig = np.array(self._control.target_signal) #xaxis = np.arange(0,len(sig)) curve1 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.black) pen.setStyle(QtCore.Qt.SolidLine) curve1.setPen(pen) curve1.attach(self._ui.qwtPlot) curve2 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.red) pen.setStyle(QtCore.Qt.DashLine) curve2.setPen(pen) curve2.attach(self._ui.qwtPlot) curve3 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.blue) pen.setStyle(QtCore.Qt.SolidLine) curve3.setPen(pen) curve3.setYAxis(1) curve3.attach(self._ui.qwtPlot) curve3.setData(times1, self._control.stage_zs) curve1.setData(times2, sig) curve2.setData(np.array([times2[0], times2[-1]]), np.array([targetsig, targetsig])) self._ui.qwtPlot.replot() curve1.detach() curve2.detach() curve3.detach()
def do_compare_max(self, x_values): ### instantiate the envelop that will show min/max deviations self._max_envelop = self._y_values self._min_envelop = self._y_values self._max_crv = Qwt.QwtPlotCurve('Zoomed max curve') self._max_crv.attach(self._plotter) self._min_crv = Qwt.QwtPlotCurve('Zoomed min curve') self._min_crv.attach(self._plotter) self._max_crv.setData(x_values, self._max_envelop) self._min_crv.setData(x_values, self._min_envelop) self._compare_max = True
def __init__(self, name, penWidth, lineColor, fillColor, plot): self.__curve__ = Qwt.QwtPlotCurve(name) pen = QtGui.QPen(lineColor) pen.setWidth(penWidth) self.__curve__.setPen(pen) self.__curve__.setBrush(fillColor) self.__curve__.attach(plot) #work around to get nicer plotting. self.__curveExt__ = Qwt.QwtPlotCurve(name + " extra") self.__curveExt__.setPen(QtGui.QPen(lineColor)) self.__curveExt__.attach(plot)
def __init__(self, titlePlot="noTitleSet", legendCurveOne="noLegendSet", legendCurveTwo=None, *args): #, *args Qwt.QwtPlot.__init__(self, *args) #, *args #print "TOTO:"+str(*args) self.setCanvasBackground(Qt.Qt.white) self.alignScales() # Initialize data #self.x = arange(0.0, 100.1, 0.5) self.x = arange(0.0, 500.1, 0.5) self.y = zeros(len(self.x), Float) self.z = zeros(len(self.x), Float) self.setTitle(titlePlot) self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend) self.curveOne = Qwt.QwtPlotCurve(legendCurveOne) self.curveOne.attach(self) self.setMarker(50, "Welcome\n") #self.startTimer(50) self.phase = 0.0 self.isAnalysed = False self.legendCurveTwo = legendCurveTwo if not legendCurveTwo == None: #and not self.isAnalysed: self.curveTwo = Qwt.QwtPlotCurve(legendCurveTwo) self.curveTwo.attach(self) #to add yellow circles #if not legendCurveTwo==None: # self.curveTwo.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, # Qt.QBrush(), # Qt.QPen(Qt.Qt.yellow), # Qt.QSize(7, 7))) self.curveOne.setPen(Qt.QPen(Qt.Qt.red)) if not legendCurveTwo == None: self.curveTwo.setPen(Qt.QPen(Qt.Qt.blue)) mY = Qwt.QwtPlotMarker() mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mY.setLineStyle(Qwt.QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time (s)") self.setAxisTitle(Qwt.QwtPlot.yLeft, "Value [C]")
def __init__(self, *args): apply(Qwt.QwtPlot.__init__, (self, ) + args) self.setTitle('Power spectrum') self.setCanvasBackground(Qt.Qt.white) # grid self.grid = Qwt.QwtPlotGrid() self.grid.enableXMin(True) self.grid.setMajPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.SolidLine)) self.grid.attach(self) # axes self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Frequency [Hz]') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Power Spectrum [dBc/Hz]') self.setAxisMaxMajor(Qwt.QwtPlot.xBottom, 10) self.setAxisMaxMinor(Qwt.QwtPlot.xBottom, 0) self.setAxisMaxMajor(Qwt.QwtPlot.yLeft, 10) self.setAxisMaxMinor(Qwt.QwtPlot.yLeft, 0) # curves self.curve2 = Qwt.QwtPlotCurve('PSTrace2') self.curve2.setPen(Qt.QPen(Qt.Qt.magenta, FFTPENWIDTH)) self.curve2.setYAxis(Qwt.QwtPlot.yLeft) self.curve2.attach(self) self.curve1 = Qwt.QwtPlotCurve('PSTrace1') self.curve1.setPen(Qt.QPen(Qt.Qt.blue, FFTPENWIDTH)) self.curve1.setYAxis(Qwt.QwtPlot.yLeft) self.curve1.attach(self) self.triggerval = 0.0 self.maxamp = 100.0 self.maxamp2 = 100.0 self.freeze = 0 self.average = 0 self.avcount = 0 self.logy = 1 self.datastream = None self.dt = 1.0 / samplerate self.df = 1.0 / (fftbuffersize * self.dt) self.f = np.arange(0.0, samplerate, self.df) self.a1 = 0.0 * self.f self.a2 = 0.0 * self.f self.curve1.setData(self.f, self.a1) self.curve2.setData(self.f, self.a2) self.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 12.5 * initfreq) self.setAxisScale(Qwt.QwtPlot.yLeft, -120.0, 0.0) self.startTimer(100) self.replot()
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) # make a QwtPlot widget self.plotLayout().setMargin(0) self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(1) self.setTitle('QwtImagePlot: (un)zoom & (un)hide') # self.setAutoLegend(0) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, 'time (s)') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'frequency (Hz)') # insert a few curves self.cSin = Qwt.QwtPlotCurve('y = pi*sin(x)') self.cCos = Qwt.QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2') self.cSin.attach(self) self.cCos.attach(self) # set curve styles self.cSin.setPen(Qt.QPen(Qt.Qt.green, 2)) self.cCos.setPen(Qt.QPen(Qt.Qt.black, 2)) self.xzoom_loc = None self.yzoom_loc = None # attach a grid grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # create zoom curve self.zoom_outline = Qwt.QwtPlotCurve() # create and initialize an image display self.plotImage = QwtPlotImage(self) self.plotImage.attach(self) self.gain = 2.0 self.updateDisplay() self.zoomStack = [] self.setMouseTracking(True) self.spy = Spy(self.canvas()) self.prev_xpos = None self.prev_ypos = None self.connect(self, Qt.SIGNAL("legendClicked(QwtPlotItem*)"), self.toggleVisibility) self.connect(self.spy, Qt.SIGNAL("MouseMove"), self.setPosition) self.connect(self.spy, Qt.SIGNAL("MousePress"), self.onmousePressEvent) self.connect(self.spy, Qt.SIGNAL("MouseRelease"), self.onmouseReleaseEvent)
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) # make a QwtPlot widget self.setTitle('SimpleDemo.py') self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend) # a variation on the C++ example self.plotLayout().setAlignCanvasToScales(True) grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->') # insert a few curves cSin = Qwt.QwtPlotCurve('y = sin(x)') cSin.setPen(Qt.QPen(Qt.Qt.red)) cSin.attach(self) cCos = Qwt.QwtPlotCurve('y = cos(x)') cCos.setPen(Qt.QPen(Qt.Qt.blue)) cCos.attach(self) # initialize the data cSin.setData(SimpleData(math.sin, 100)) cCos.setData(SimpleData(math.cos, 100)) # insert a horizontal marker at y = 0 mY = Qwt.QwtPlotMarker() mY.setLabel(Qwt.QwtText('y = 0')) mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mY.setLineStyle(Qwt.QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) # insert a vertical marker at x = 2 pi mX = Qwt.QwtPlotMarker() mX.setLabel(Qwt.QwtText('x = 2 pi')) mX.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mX.setLineStyle(Qwt.QwtPlotMarker.VLine) mX.setXValue(2 * math.pi) mX.attach(self) # replot self.replot()
def __init__(self): QtGui.QMainWindow.__init__(self) ''' self.view = pg.GraphicsView() self.graph = pg.PlotItem() self.view.setCentralWidget(self.graph) self.setCentralWidget(self.view) testx = np.random.rand(10) testy = np.random.rand(10) self.graph.plot(testx,testy,pen=None,symbol='o') ''' self.qwtPlot = Qwt5.QwtPlot(self) self.setCentralWidget(self.qwtPlot) #self.qwtPlot.setGeometry(QtCore.QRect(260, 400, 581, 200)) self.scatter = Qwt5.QwtPlotCurve('') self.scatter.attach(self.qwtPlot) self.scatter.setPen(QtGui.QPen(QtCore.Qt.NoPen)) scatter_symbol = Qwt5.QwtSymbol(Qwt5.QwtSymbol.Ellipse, QtGui.QBrush(QtCore.Qt.red), QtGui.QPen(QtCore.Qt.red), QtCore.QSize(7, 7)) self.scatter.setSymbol(scatter_symbol) self.scatterAll = Qwt5.QwtPlotCurve('') self.scatterAll.attach(self.qwtPlot) self.scatterAll.setPen(QtGui.QPen(QtCore.Qt.NoPen)) scatter_symbol = Qwt5.QwtSymbol(Qwt5.QwtSymbol.Ellipse, QtGui.QBrush(QtCore.Qt.black), QtGui.QPen(QtCore.Qt.black), QtCore.QSize(3, 3)) self.scatterAll.setSymbol(scatter_symbol) self.setGeometry(40, 40, 512, 512) self.cell_size = 32 self.threshold = 200 self.fof = fof.MedFastObjectFinder(self.cell_size, self.threshold) #self.setLayout(vbox) self.statusBar = QtGui.QStatusBar(self) self.setStatusBar(self.statusBar) self.allXs = np.array([]) self.allYs = np.array([])
def doPlot(self, data, data_mean, means, means2): if self.plotRealtime: xaxis = np.arange(0, len(data)) curve1 = Qwt5.QwtPlotCurve('') curve2 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.black) pen.setStyle(QtCore.Qt.SolidLine) curve1.setPen(pen) curve1.attach(self._ui.qwtPlot) curve1.setData(xaxis, data) pen = QtGui.QPen(QtCore.Qt.red) pen.setStyle(QtCore.Qt.SolidLine) curve2.setPen(pen) curve2.attach(self._ui.qwtPlot) curve2.setData(np.array([xaxis[0], xaxis[-1]]), np.array([data_mean, data_mean])) self._ui.qwtPlot.replot() curve1.detach() curve2.detach() else: xaxis = np.arange(0, len(means)) curve1 = Qwt5.QwtPlotCurve('') curve2 = Qwt5.QwtPlotCurve('') curve3 = Qwt5.QwtPlotCurve('') pen = QtGui.QPen(QtCore.Qt.black) pen.setStyle(QtCore.Qt.SolidLine) pen2 = QtGui.QPen(QtCore.Qt.blue) pen2.setStyle(QtCore.Qt.SolidLine) pen3 = QtGui.QPen(QtCore.Qt.red) pen3.setStyle(QtCore.Qt.SolidLine) curve1.setPen(pen) curve1.attach(self._ui.qwtPlot) if not self._ui.plotOnlyPos_checkBox.isChecked(): curve1.setData(xaxis, means) curve2.setPen(pen2) curve2.attach(self._ui.qwtPlot) curve3.setPen(pen3) curve3.attach(self._ui.qwtPlot) if means2[0] < 100: xaxis2 = np.arange(0, len(means2)) if not self._ui.plotOnlyPos_checkBox.isChecked(): curve2.setData(xaxis2, means2) curve3.setData(xaxis2, np.array(means) / (2.0 * np.array(means2))) self._ui.qwtPlot.replot() curve1.detach() curve2.detach() curve3.detach()
def __init__(self, nplots, *args): """ Initializes the graph plotting. The usual parameters are available. :Parameters: nplots Number of plots in the same window. """ Qwt.QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.white) grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setMajPen(QPen(Qt.black, 0, Qt.DotLine)) self.__nplots = nplots self.__curves = [] colors = [ Qt.red, Qt.darkCyan, Qt.green, Qt.darkYellow, Qt.cyan, Qt.magenta ] for i in xrange(nplots): new_curve = Qwt.QwtPlotCurve('') new_curve.attach(self) new_curve.setPen(QPen(colors[i % 6])) new_curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) self.__curves.append(new_curve)
def __init__(self, y_axis, plot_list, *args): Qwt.QwtPlot.__init__(self, *args) self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time [s]') self.setAxisTitle(Qwt.QwtPlot.yLeft, y_axis) self.has_legend = plot_list[0][0] != '' if self.has_legend: legend = Qwt.QwtLegend() legend.setItemMode(Qwt.QwtLegend.CheckableItem) self.insertLegend(legend, Qwt.QwtPlot.RightLegend) self.setAutoReplot(True) self.curve = [] self.data_x = [] self.data_y = [] for x in plot_list: c = Qwt.QwtPlotCurve(x[0]) self.curve.append(c) self.data_x.append([]) self.data_y.append([]) c.attach(self) c.setPen(x[1]) self.show_curve(c, True) if self.has_legend: self.legendChecked.connect(self.show_curve)
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.Qt.white) self.alignScales() # Initialize data self.x = arange(0, 501, 1) self.y = zeros(len(self.x), Float) self.setTitle("Plot") self.curveR = Qwt.QwtPlotCurve() self.curveR.attach(self) self.curveR.setPen(Qt.QPen(Qt.Qt.blue)) self.setAxisTitle(Qwt.QwtPlot.xBottom, "Framecount") self.setAxisTitle(Qwt.QwtPlot.yLeft, "Values") self.curveR.setData(self.x, self.y) self.marker = m = Qwt.QwtPlotMarker() m.setValue(0, 0) m.setLineStyle(Qwt.QwtPlotMarker.VLine) m.setLinePen(Qt.QPen(Qt.Qt.green, 2, Qt.Qt.DashDotLine)) text = Qwt.QwtText('') text.setColor(Qt.Qt.green) text.setBackgroundBrush(Qt.Qt.gray) text.setFont(Qt.QFont(self.fontInfo().family(), 12, Qt.QFont.Bold)) m.setLabel(text) m.attach(self)
def __init__(self, control): inLib.DeviceUI.__init__(self, control, 'andor.emccd.emccd_design') self._ui.pushButtonShutter.clicked.connect(self.toggleShutter) self._ui.pushButtonSnapshot.clicked.connect(self.saveSnapshot) self._ui.labelDisplay.paintEvent = self._labelDisplay_paintEvent self._ui.checkBoxAutoscale.stateChanged.connect(self.setAutoscale) # A histogram of the current frame: self._ui.qwtPlotHistogram.enableAxis(0, False) self._ui.qwtPlotHistogram.enableAxis(2, False) canvas = self._ui.qwtPlotHistogram.canvas().setLineWidth(0) #canvas.setLineWidth(10) self._histogram = Qwt5.QwtPlotCurve('') self._histogram.setStyle(Qwt5.QwtPlotCurve.Sticks) self._histogram.attach(self._ui.qwtPlotHistogram) em_min, em_max = self._control.getEMGainRange() self._ui.horizontalSliderGain.setRange(em_min, em_max) em_gain = self._control.getEMCCDGain() self._ui.labelGain.setText('EM Gain: ' + str(em_gain)) self._ui.horizontalSliderGain.setValue(em_gain) self._ui.horizontalSliderGain.valueChanged.connect(self.setEMCCDGain) self._autoscale = True self._pixmap = None self._cmap = None #self._cmap = qext.QColortables8.spectral self._vmin = 0.0 self._vmax = 65535.0 # A timer to update the image: self._updater = QtCore.QTimer() self._updater.timeout.connect(self._update) self._updater.start(100)
def __init__(self, parent=None): super(MainDialog, self).__init__(parent) self.setupUi(self) self.timer = QTimer(self) self.timer.timeout.connect(self.acquerirMesures) self.timer.setInterval(100) self.graph.setTitle("Sound Level") self.graph.setAxisTitle(0, "Sound Level (dBA)") self.graph.setAxisTitle(2, "Time (x10ms)") self.graph.setAxisScale(2, 0, 21, 0) self.graph.setAxisScale(0, 0, 160, 0) self.graph.setCanvasBackground(Qt.Qt.white) self.curveR = Qwt.QwtPlotCurve("Data Moving Right") self.curveR.attach(self.graph) pen = Qt.QPen(Qt.Qt.green) pen.setWidth(5) self.curveR.setPen(pen) self.x = range(0, 21) self.y = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] self.seuil = 60.0 self.filename = "sound" + str(1) + ".csv" self.t = 0
def plotData(self, key, axis=0, x=None, y=None): """ plot data (x, y) on the graph axis "axis" if axis is zero then remove the plot from the graph """ # First if the plot exists then delete it! if not self.curve.has_key(key) and not axis: return True if self.curve.has_key(key) and not axis: # We are plotting this curve self.curve[key].attach(None) self.curve.__delitem__(key) return True if not self.curve.has_key(key): c = Qwt.QwtPlotCurve(key) self.setLineStyle(c) self.curve[key] = c self.curve[key].setData(x, y) if axis & 1: self.curve[key].setYAxis(Qwt.QwtPlot.yLeft) if axis & 2: self.curve[key].setYAxis(Qwt.QwtPlot.yRight) self.curve[key].attach(self) return True
def __init__(self, *args): Qt.QWidget.__init__(self, *args) layout = Qt.QGridLayout(self) # try to create a plot for SciPy arrays try: # import does_not_exist import numpy # make a curve and copy the data numpy_curve = Qwt.QwtPlotCurve('y = lorentzian(x)') x = numpy.arange(0.0, 10.0, 0.01) y = lorentzian(x) numpy_curve.setData(x, y) # here, we know we can plot NumPy arrays numpy_plot = Qwt.QwtPlot(self) numpy_plot.setTitle('numpy array') numpy_plot.setCanvasBackground(Qt.Qt.white) numpy_plot.plotLayout().setCanvasMargin(0) numpy_plot.plotLayout().setAlignCanvasToScales(True) # insert a curve and make it red numpy_curve.attach(numpy_plot) numpy_curve.setPen(Qt.QPen(Qt.Qt.red)) layout.addWidget(numpy_plot, 0, 0) numpy_plot.replot() except ImportError, message: print "%s: %s" % (ImportError, message) print "Install NumPy to plot plot NumPy arrays"
def create_plot2(self): self.Trigger2 = 0 self.MaxSamplesPlot2 = 6000 plot2 = Qwt.QwtPlot(self) plot2.setCanvasBackground(Qt.black) plot2.setAxisTitle(Qwt.QwtPlot.xBottom, '') plot2.setAxisScale(Qwt.QwtPlot.xBottom, 0, 60, 5) plot2.setAxisTitle(Qwt.QwtPlot.yLeft, 'Temperature [degC]') plot2.setAxisAutoScale(Qwt.QwtPlot.yLeft) plot2.replot() curve2 = [None] * 3 pen = [ QPen(QColor('limegreen')), QPen(QColor('red')), QPen(QColor('magenta')) ] for i in range(3): curve2[i] = Qwt.QwtPlotCurve('') curve2[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) pen[i].setWidth(2) curve2[i].setPen(pen[i]) curve2[i].attach(plot2) return plot2, curve2
def create_curves(self, labels, this_range, show_legend=True): # delete / detach all old curves for c in self.curves: c.detach() # create new curves self.curves = [] for i, curve_label in enumerate(labels): # Create legend item and set font curve_label_t = Qwt.QwtText(str(curve_label)) f = curve_label_t.font() f.setPointSize(8) curve_label_t.setFont(f) curve = Qwt.QwtPlotCurve(curve_label_t) curve.attach(self) curve.setPen(Qt.QPen(self.colors[i % len(self.colors)])) curve.setRenderHint(QwtPlotItem.RenderAntialiased, USE_ANTIALIASING) self.curves.append(curve) if show_legend: legend = Qwt.QwtLegend() self.insertLegend(legend, Qwt.QwtPlot.BottomLegend) # self.insertLegend(legend, Qwt.QwtPlot.ExternalLegend); xaxis_title = Qwt.QwtText("Time (seconds)") yaxis_title = Qwt.QwtText("Intensity") self.setAxisTitle(Qwt.QwtPlot.xBottom, xaxis_title) self.setAxisTitle(Qwt.QwtPlot.yLeft, yaxis_title)
def initQwtPlot(self): self.PlotBuff = '' self.PlotData = [0] * 1000 self.PlotCurve = Qwt.QwtPlotCurve() self.PlotCurve.attach(self.qwtPlot) self.PlotCurve.setData(range(1, len(self.PlotData) + 1), self.PlotData)
def __init__(self, window, name): self.window = window self.data = list(zeros(XRANGE, Float)) ##starts Y with zeros self.x = arange(0.0, 2000, 0.5) self.curve = Qwt.QwtPlotCurve(name) self.treeItem = None self.name = name
def create_plot(self): """ Purpose: create the pyqwt plot Return: return a list containing the plot and the list of the curves """ plot = Qwt.QwtPlot(self) plot.setCanvasBackground(Qt.black) plot.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time') plot.setAxisScale(Qwt.QwtPlot.xBottom, 0, 10, 1) plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Distance') plot.setAxisScale(Qwt.QwtPlot.yLeft, LeftYMIN, LeftYMAX, (LeftYMAX - LeftYMIN) / 5) plot.setAxisTitle(Qwt.QwtPlot.yRight, 'Distance') plot.setAxisScale(Qwt.QwtPlot.yRight, RightYMIN, RightYMAX, (RightYMAX - RightYMIN) / 5) plot.replot() curve = [None] * 3 pen = [ QPen(QColor('limegreen')), QPen(QColor('red')), QPen(QColor('blue')) ] for i in range(3): curve[i] = Qwt.QwtPlotCurve('') curve[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) pen[i].setWidth(2) curve[i].setPen(pen[i]) curve[i].attach(plot) return plot, curve
def create_plot(self): self.Trigger1 = 0 self.MaxSamplesPlot1 = 6000 plot = Qwt.QwtPlot(self) plot.setCanvasBackground(Qt.black) plot.setAxisTitle(Qwt.QwtPlot.xBottom, '') plot.setAxisScale(Qwt.QwtPlot.xBottom, 0, 20, 5) plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Heart Rhythm [Raw Value]') plot.setAxisAutoScale(Qwt.QwtPlot.yLeft) plot.replot() curve = [None] * 3 pen = [ QPen(QColor('limegreen')), QPen(QColor('red')), QPen(QColor('magenta')) ] for i in range(3): curve[i] = Qwt.QwtPlotCurve('') curve[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) pen[i].setWidth(2) curve[i].setPen(pen[i]) curve[i].attach(plot) return plot, curve
def makeplot(self): '''set up plotting''' # draw a plot in the frame p = Qwt5.QwtPlot(self.axes) c = Qwt5.QwtPlotCurve('FR:WFX') c.attach(p) c.setPen(QtGui.QPen(QtCore.Qt.blue)) # === Plot Customization === # set background to black p.setCanvasBackground(QtCore.Qt.black) # stop flickering border p.canvas().setFocusIndicator(Qwt5.QwtPlotCanvas.NoFocusIndicator) # set zoom colour # for z in p.zoomers: # z.setRubberBandPen(QtGui.QPen(QtCore.Qt.white)) # set fixed scale p.setAxisScale(Qwt5.QwtPlot.yLeft, -1e7, 1e7) p.setAxisScale(Qwt5.QwtPlot.xBottom, 0, 2500) # automatically redraw when data changes p.setAutoReplot(True) # reset plot zoom (the default is 1000 x 1000) # for z in p.zoomers: # z.setZoomBase() self.p = p self.c = c self.axes.layout().addWidget(self.p)
def do_compare(self): print 'in zoomwin do_compare' if self._compare_max: self.stop_compare_max() self._compare_max = False else: self._max_envelop = self._y_values self._min_envelop = self._y_values self._max_crv = Qwt.QwtPlotCurve('Zoomed max curve') self._max_crv.attach(self._plotter) self._min_crv = Qwt.QwtPlotCurve('Zoomed min curve') self._min_crv.attach(self._plotter) self._max_crv.setData(x_values, self._max_envelop) self._min_crv.setData(x_values, self._min_envelop) self._compare_max = True self.reset_max()