def __init__(self, comm, parent=None): """Connents newMessage handler to OvenComm instance and sets up common plot format.""" super(OvenPlot, self).__init__(parent) self.comm = comm self.setCanvasBackground(QtCore.Qt.white) # plot grid grid = Qwt.QwtPlotGrid() pen = QtGui.QPen(QtCore.Qt.DotLine) pen.setColor(QtCore.Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self) # plot legend and x-axis (y-axis handled in derived classes) self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend) self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time (seconds)") self.times = [] self.time_offset = 0.0 self.max_idle = (120 * 4) self.prevstate = 'idle' self.reset_plot() comm.newMessage.connect(self.newMessage_handler)
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) # create a plot with a white canvas self.setCanvasBackground(Qt.Qt.white) # set plot layout self.plotLayout().setMargin(0) self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # attach a grid grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # attach a x-axis xaxis = CartesianAxis(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft) xaxis.attach(self) self.enableAxis(Qwt.QwtPlot.xBottom, False) # attach a y-axis yaxis = CartesianAxis(Qwt.QwtPlot.yLeft, Qwt.QwtPlot.xBottom) yaxis.attach(self) self.enableAxis(Qwt.QwtPlot.yLeft, False) # set default grid bounds self.setAxisScale(Qwt.QwtPlot.xBottom, -10, 10) self.setAxisScale(Qwt.QwtPlot.yLeft, -10, 10) self.replot() # enable drawing hint for qwt self.canvas().setPaintAttribute(True, Qwt.QwtPlotCurve.ClipPolygons) # attach eventFilter self.installEventFilter(self) # initialize local variables self.__movable = True
def initGrid(self): """Create a grid on the plot """ self.grid = Qwt.QwtPlotGrid() self.grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) self.grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine)) self.grid.attach(self)
def __init__(self, parent=None): Qt.QMainWindow.__init__(self, parent) # Initialize a QwPlot central widget self.plot = Qwt.QwtPlot(self) self.plot.setTitle('left-click & drag to zoom') self.plot.setCanvasBackground(Qt.Qt.white) self.plot.plotLayout().setCanvasMargin(0) self.plot.plotLayout().setAlignCanvasToScales(True) self.setCentralWidget(self.plot) grid = Qwt.QwtPlotGrid() pen = Qt.QPen(Qt.Qt.DotLine) pen.setColor(Qt.Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self.plot) self.__initTracking() self.__initZooming() self.__initToolBar() # Finalize self.counter.setValue(10) self.go(self.counter.value())
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) self.cpu_count=psutil.cpu_count() self.x = arange(-60,0, 1) self.cpu_percent=[] self.curve=[] legend = Qwt.QwtLegend() legend.setItemMode(Qwt.QwtLegend.CheckableItem) self.insertLegend(legend, Qwt.QwtPlot.RightLegend) for cpu_number in range(self.cpu_count): self.cpu_percent.append(0*self.x) self.curve.append(Qwt.QwtPlotCurve('CPU'+str(cpu_number))) self.curve[cpu_number].attach(self) self.curve[cpu_number].setData(self.x, self.cpu_percent[cpu_number]) self.curve[cpu_number].setPen(QtGui.QPen(self.colors[cpu_number], 2)) self.showCurve(self.curve[cpu_number], True) #ustawienie osi self.setAxisScale(Qwt.QwtPlot.yLeft, 0, 100) self.setAxisTitle(Qwt.QwtPlot.yLeft, "Usage [%]") #Grid grid = Qwt.QwtPlotGrid() pen = QtGui.QPen(Qt.DotLine) pen.setColor(Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self) self.startTimer(1000) self.connect(self,QtCore.SIGNAL('legendChecked(QwtPlotItem*, bool)'),self.showCurve) #przepisac na nowy styl self.replot()
def __init__(self, parent=None, attributes=[Qt.Qt.black, 1, Qt.Qt.white], *args): super(BarPlot, self).__init__(parent, *args) self.curves = {} self.attributes = attributes # set plot default layout self.plotLayout().setMargin(0) self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # set X Axis bottomAxis = self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Standard deviation') #self.setAxisScaleDraw(Qwt.QwtPlot.xBottom, TextScaleDraw(month)) self.setAxisScale(Qwt.QwtPlot.xBottom, 0, 30) #self.setAxisMaxMajor(Qwt.QwtPlot.xBottom, 36) # set a maximum of 10 Major ticks #self.setAxisMaxMinor(Qwt.QwtPlot.xBottom, 0) # force zero minor ticks self.enableAxis(Qwt.QwtPlot.xBottom) # set Y Axis self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Counts') self.setAxisScale(Qwt.QwtPlot.yLeft, 0, 100) grid = Qwt.QwtPlotGrid() pen = Qt.QPen(Qt.Qt.DotLine) pen.setColor(Qt.Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self)
def setupPlot(self): self.qwtPlot.setCanvasBackground(Qt.Qt.white) self.alignScales() # self.qwtPlot.enableAxis(Qwt.QwtPlot.xBottom, False) # self.qwtPlot.enableAxis(Qwt.QwtPlot.yLeft, False) TODO Check why this was here at all self.qwtPlot.CurveSignal = Qwt.QwtPlotCurve("EEG Signal") self.qwtPlot.CurveSignal.attach(self.qwtPlot) self.qwtPlot.CurveSignal.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.qwtPlot) # grid self.qwtPlot.grid = Qwt.QwtPlotGrid() self.qwtPlot.grid.enableY(False) self.qwtPlot.grid.enableX(True) self.qwtPlot.grid.enableXMin(True) self.qwtPlot.grid.setMajPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.SolidLine)) self.qwtPlot.grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DashLine)) self.qwtPlot.grid.attach(self.qwtPlot) self.qwtPlot.startTimer(50) self.qwtPlot.phase = 0.0
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 make(): # create a plot with a white canvas demo = Qwt.QwtPlot(Qwt.QwtText("Errorbar Demonstation")) demo.setCanvasBackground(Qt.Qt.white) demo.plotLayout().setAlignCanvasToScales(True) grid = Qwt.QwtPlotGrid() grid.attach(demo) grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # calculate data and errors for a curve with error bars x = arange(0, 10.1, 0.5, Float) y = sin(x) dy = 0.2 * abs(y) # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars dx = 0.2 # all error bars the same size errorOnTop = False # uncomment to draw the curve on top of the error bars # errorOnTop = True # uncomment to draw the error bars on top of the curve curve = ErrorBarPlotCurve( x=x, y=y, dx=dx, dy=dy, curvePen=Qt.QPen(Qt.Qt.black, 2), curveSymbol=Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.red), Qt.QPen(Qt.Qt.black, 2), Qt.QSize(9, 9)), errorPen=Qt.QPen(Qt.Qt.blue, 2), errorCap=10, errorOnTop=errorOnTop, ) curve.attach(demo) demo.resize(400, 300) demo.show() return demo
def __init__(self, *args): super(QwtChart, self).__init__(*args) # set title self.setTitle(u'<h4><font color=red>图表</font></h4>') # bgcolor self.setCanvasBackground(Qt.Qt.white) # legend self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend) # a variation on the C++ example self.plotLayout().setAlignCanvasToScales(True) # grid grid = Qwt.QwtPlotGrid() grid.setPen(QtGui.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine)) grid.attach(self) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, u'X') self.setAxisTitle(Qwt.QwtPlot.yLeft, u'Amplitude') # set Scale Range self.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 1000.0) self.setAxisScale(Qwt.QwtPlot.yLeft, -10.0, 10.0) # picker self.picker = Qwt.QwtPlotPicker( Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PointSelection | Qwt.QwtPicker.DragSelection, Qwt.QwtPlotPicker.CrossRubberBand, Qwt.QwtPicker.AlwaysOn, self.canvas()) self.picker.setRubberBandPen(QtGui.QPen(Qt.Qt.red)) self.picker.setTrackerPen(QtGui.QPen(Qt.Qt.red)) self.connect(self.picker, QtCore.SIGNAL('moved(const QPoint &)'), self.moved) # 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.setLinePen(Qt.QPen(Qt.Qt.cyan, 1, Qt.Qt.DashDotLine)) mY.setYValue(0.0) mY.attach(self) # insert a vertical marker at x = 500 mX = Qwt.QwtPlotMarker() mX.setLabel(Qwt.QwtText('x = 500')) mX.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mX.setLineStyle(Qwt.QwtPlotMarker.VLine) mX.setLinePen(QtGui.QPen(Qt.Qt.cyan, 1, Qt.Qt.DashDotLine)) mX.setXValue(500) mX.attach(self) #Initialize data self.curves = [] self.dataLength = 1000 self.x = np.arange(0.0, 1001.0, 1.0)
def __init__(self, parent, logger): ClassPlot.__init__(self) # store the logger instance self.logger = logger # we do not need caching self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintCached, False) self.canvas().setPaintAttribute(Qwt.QwtPlotCanvas.PaintPacked, False) # attach a grid grid = Qwt.QwtPlotGrid() grid.setMajPen(Qt.QPen(Qt.Qt.lightGray)) grid.attach(self) xtitle = Qwt.QwtText('Time (ms)') xtitle.setFont(QtGui.QFont(8)) self.setAxisTitle(Qwt.QwtPlot.xBottom, xtitle) self.setAxisScale(Qwt.QwtPlot.yLeft, -1., 1.) # self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time (ms)') self.xmin = 0. self.xmax = 1. ytitle = Qwt.QwtText('Signal') ytitle.setFont(QtGui.QFont(8)) self.setAxisTitle(Qwt.QwtPlot.yLeft, ytitle) # self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Signal') self.setAxisScale(Qwt.QwtPlot.yLeft, -1., 1.) self.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLinearScaleEngine()) self.paint_time = 0. self.canvas_width = 0 self.dual_channel = False # insert an additional curve for the second channel # (ClassPlot already has one by default) self.curve2 = Qwt.QwtPlotCurve("Ch2") self.curve2.setPen(QtGui.QPen(Qt.Qt.blue)) #self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) #self.curve2.attach(self) # gives an appropriate title to the first curve # (for the legend) self.curve.setTitle("Ch1") # picker used to display coordinates when clicking on the canvas self.picker = picker(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPlotPicker.CrossRubberBand, Qwt.QwtPicker.ActiveOnly, self.canvas()) self.cached_canvas = self.canvas() #need to replot here for the size Hints to be computed correctly (depending on axis scales...) self.replot()
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 __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.Qt.white) #self.alignScales() # self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend); self.curve = Qwt.QwtPlotCurve('Unfiltered Spectrum') self.curve.setPen(Qt.QPen(Qt.Qt.red)) self.curve.attach(self) # Make 100 "gray" curves self.curve_gray = [] for i in xrange(50): curve = Qwt.QwtPlotCurve('Cumulative Filter Attenuation') if i > 0: curve.setItemAttribute(Qwt.QwtPlotItem.Legend, False) curve.setPen(Qt.QPen(Qt.Qt.gray)) curve.attach(self) self.curve_gray.append(curve) self.curve2 = Qwt.QwtPlotCurve('Filtered Spectrum') self.curve2.setPen(Qt.QPen(Qt.Qt.blue)) self.curve2.attach(self) self.curve3 = Qwt.QwtPlotCurve() self.curve3.setItemAttribute(Qwt.QwtPlotItem.Legend, False) self.curve3.setPen(Qt.QPen(Qt.Qt.green)) self.curve3.attach(self) self.curve_white = Qwt.QwtPlotCurve() self.curve_white.setItemAttribute(Qwt.QwtPlotItem.Legend, False) self.curve_white.setPen(Qt.QPen(Qt.Qt.white)) self.curve_white.attach(self) self.curve_green = Qwt.QwtPlotCurve('Mono Energy') self.curve_green.setPen(Qt.QPen(Qt.Qt.darkGreen)) self.curve_green.attach(self) mY = Qwt.QwtPlotMarker() mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop) mY.setLineStyle(Qwt.QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) self.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLog10ScaleEngine()) self.setAxisScaleEngine(Qwt.QwtPlot.yLeft, Qwt.QwtLog10ScaleEngine()) # Add grid to plot grid = Qwt.QwtPlotGrid() pen = Qt.QPen(Qt.Qt.DotLine) pen.setColor(Qt.Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self)
def initPlots(self): self.plot3.clear() self.plot3.setAxisScale(self.plot1.xBottom, -4, 4) self.plot3.setAxisScale(self.plot1.yLeft, -4, 4) self.plot1.clear() self.plot1.setTitle("Search MS") self.plot1.setAxisTitle(Qwt.QwtPlot.yLeft, 'Intensity') grid = Qwt.QwtPlotGrid() pen = QPen(Qt.DotLine) pen.setColor(Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self.plot1) self.plot1.setAxisScale(self.plot1.yLeft, 0, 1.1 * np.max(self.mass)) color = QColor('black') curve = Qwt.QwtPlotCurve("test1") pen = QPen(color) pen.setWidth(1) curve.setPen(pen) #self.axis= np.arange(len(self.mass)) curve.setData(self.axis, self.mass) curve.setStyle(Qwt.QwtPlotCurve.Sticks) curve.attach(self.plot1) for i in range(len(self.peak_MS)): text_MS = Qwt.QwtText('%s' % (str(self.peak_MS[i][0]))) marker_MS = Qwt.QwtPlotMarker() marker_MS.setLabelAlignment(Qt.AlignCenter | Qt.AlignTop) marker_MS.setLabel(text_MS) marker_MS.setValue(self.peak_MS[i][0], self.peak_MS[i][1]) marker_MS.attach(self.plot1) self.plot1.replot() self.plot2.clear() self.plot2.setTitle("NIST MS") # self.plot2.setAxisTitle(Qwt.QwtPlot.xBottom, 'Raman shift (cm-1)') self.plot2.setAxisTitle(Qwt.QwtPlot.yLeft, 'Intensity') grid = Qwt.QwtPlotGrid() pen = QPen(Qt.DotLine) pen.setColor(Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self.plot2) self.plot2.replot()
def __init__(self, parent, **kwargs): #signals = [] pythics.libcontrol.Control.__init__(self, parent, **kwargs) self._widget = Qwt.QwtPlot() self._grid = Qwt.QwtPlotGrid() self._grid.enableX(False) self._grid.enableY(False) self._grid.attach(self._widget) self._elements = dict() p = self._widget g = self._grid if 'background' in kwargs: value = kwargs.pop('background') p.setCanvasBackground(QtGui.QColor(value)) else: # default white background color self._widget.setCanvasBackground(QtCore.Qt.white) if 'margin' in kwargs: value = kwargs.pop('margin') p.setMargin(value) if 'x_auto_scale' in kwargs: value = kwargs.pop('x_auto_scale') p.setAxisAutoScale(Qwt.QwtPlot.xBottom, value) if 'y_auto_scale' in kwargs: value = kwargs.pop('y_auto_scale') p.setAxisAutoScale(Qwt.QwtPlot.yLeft, value) if 'x_scale' in kwargs: value = kwargs.pop('x_scale') # NEED TO CONVERT VALUE TO THE APPROPRIATE TYPE!!!!!!!!!!!!!!!!! p.setAxisScale(Qwt.QwtPlot.xBottom, value) if 'y_scale' in kwargs: value = kwargs.pop('y_scale') # NEED TO CONVERT VALUE TO THE APPROPRIATE TYPE!!!!!!!!!!!!!!!!! p.setAxisScale(Qwt.QwtPlot.yLeft, value) if 'title' in kwargs: value = kwargs.pop('title') p.setTitle(value) if 'x_title' in kwargs: value = kwargs.pop('x_title') p.setAxisTitle(Qwt.QwtPlot.xBottom, value) if 'y_title' in kwargs: value = kwargs.pop('y_title') p.setAxisTitle(Qwt.QwtPlot.yLeft, value) if 'x_grid' in kwargs: value = kwargs.pop('x_grid') g.enableX(value) if 'y_grid' in kwargs: value = kwargs.pop('y_grid') g.enableY(value) if 'dashed_grid' in kwargs: if kwargs.pop('dashed_grid'): grid_line = QtGui.QPen(QtCore.Qt.DashLine) g.setPen(grid_line)
def create_plot(self): self.plot = self.ui.plot self.plot.setCanvasBackground(Qt.white) self.grid = Qwt.QwtPlotGrid() self.grid.attach(self.plot) self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) self.curve = Qwt.QwtPlotCurve('') self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) self.pen = QPen(QColor('black')) self.pen.setWidth(0) self.curve.setPen(self.pen) self.curve.attach(self.plot)
def toggle_grid(self): print "toggle grid" if self.grid == None: self.grid = Qwt.QwtPlotGrid() self.grid.enableXMin(True) self.grid.setMajPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine)) self.grid.setMinPen(Qt.QPen(Qt.Qt.darkGray, 0, Qt.Qt.DotLine)) self.grid.attach(self) else: self.grid.detach() self.grid = None self.trigger_update()
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, parent=None, *args): super(NDVI_Plot, self).__init__(parent, *args) self.curves = {} #self.statCurves={} self.data = {} month = ['APR','','', 'MAY','','', 'JUN','','', 'JUL','','', 'AUG','','', 'SEP','','', \ 'OCT','','', 'NOV','','', 'DEC','','', 'JAN','','', 'FEB','','', 'MAR', '', ''] #self.series = (series_name,weight,isFilled, visible, z) self.series = [\ ('1998 - 1999',2, False, False, 0),('1999 - 2000',2, False, False, 0),\ ('2000 - 2001',2, False, False, 0),('2001 - 2002',2, False, False, 0),\ ('2002 - 2003',2, False, False, 0),('2003 - 2004',2, False, False, 0),\ ('2004 - 2005',2, False, False, 0),('2005 - 2006',2, False, False, 0),\ ('2006 - 2007',2, False, False, 0),('2007 - 2008',2, False, False, 0),\ ('Average',3, False, True, 0), ('SD Lower',0, True, True, 100),('SD Upper',0, True, True, 101)] sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setMinimumSize(QtCore.QSize(350, 0)) # self.setCanvasBackground(GemColor(217, 217, 217, 255)) # set plot default layout self.plotLayout().setMargin(0) self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # set X Axis bottomAxis = self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Time (SPOT-VGT-S10 periods)') self.setAxisScaleDraw(Qwt.QwtPlot.xBottom, TextScaleDraw(month)) self.setAxisScale(Qwt.QwtPlot.xBottom, 0, 35) self.setAxisMaxMajor(Qwt.QwtPlot.xBottom, 36) # set a maximum of 10 Major ticks self.setAxisMaxMinor(Qwt.QwtPlot.xBottom, 0) # force zero minor ticks self.enableAxis(Qwt.QwtPlot.xBottom) # set Y Axis self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Scaled NDVI') self.setAxisScale(Qwt.QwtPlot.yLeft, 0, 255) # # attach a grid grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) # self._colorList = self.createColorList()
def __init__(self, parent, xa, ya, minValue, maxValue, step, qwtPlot, colorCanvas, namePlot=u'', titleList=None): if not titleList: titleList = {} self.parent = parent self.qwtPlot = Qwt.QwtPlot( Qwt.QwtText('self.parent.scrollArea.viewport()')) if self.parent.countGraphic == 0: countGraphic = 1 else: countGraphic = self.parent.countGraphic namePlotQwtText = Qwt.QwtText(namePlot) font = QtGui.QFont() font.setWeight(8) font.setBold(False) namePlotQwtText.setFont(font) self.qwtPlot.setAutoReplot(True) self.qwtPlot.setTitle(namePlotQwtText) self.qwtPlot.setCanvasBackground(QtCore.Qt.white) megaGrid = Qwt.QwtPlotGrid() megaGrid.enableXMin(False) megaGrid.enableYMin(True) megaGrid.attach(self.qwtPlot) ca = Qwt.QwtPlotCurve() ca.setPen(QtGui.QPen(colorCanvas)) ca.setData(xa, ya) ca.attach(self.qwtPlot) self.qwtPlot.enableAxis(Qwt.QwtPlot.xTop, True) self.qwtPlot.setAxisScale(Qwt.QwtPlot.yLeft, minValue, maxValue, step) axisLen = len(xa) + 1 self.qwtPlot.setAxisScale(Qwt.QwtPlot.xBottom, 0, axisLen, 1.0) self.qwtPlot.setAxisScale(Qwt.QwtPlot.xTop, 0, axisLen, 1.0) axisScaleDraw = self.qwtPlot.axisScaleDraw(Qwt.QwtPlot.xBottom) self.qwtPlot.setAxisScaleDraw( Qwt.QwtPlot.xBottom, CMyQwtScaleDrawXBottom(axisScaleDraw, titleList)) axisScaleDraw = self.qwtPlot.axisScaleDraw(Qwt.QwtPlot.xTop) self.qwtPlot.setAxisScaleDraw( Qwt.QwtPlot.xTop, CMyQwtScaleDrawXTop(axisScaleDraw, titleList))
def __init__(self, control, ui_control): inLib.ModuleUI.__init__(self, control, ui_control, 'modules.focusLock.focusLock_design') self.updaterTime = 1100 self._ui.samples_lineEdit.setText('%i' % self._control.samples) self._ui.sampleRate_lineEdit.setText('%i' % self._control.sampleRate) self._ui.lock_lineEdit.setText('--') self._ui.updaterTime_lineEdit.setText('%i' % self.updaterTime) self._ui.samples_lineEdit.returnPressed.connect(self._setParams) self._ui.sampleRate_lineEdit.returnPressed.connect(self._setParams) self._ui.updaterTime_lineEdit.returnPressed.connect(self.setUpdaterTime) self._ui.prop_lineEdit.returnPressed.connect(self.setProp) self._ui.lock_lineEdit.returnPressed.connect(self.setLock) self._ui.current_pushButton.clicked.connect(self.currentLock) self._ui.start_pushButton.clicked.connect(self.monitorRun) self._ui.saveData_pushButton.clicked.connect(self.saveData) self._ui.saveData_pushButton.setEnabled(False) self._ui.clearData_pushButton.clicked.connect(self.clearData) self._ui.isOnFeedback_checkBox.clicked.connect(self.feedback) self.noPlot = False self.plotRealtime = True self._ui.radioButton_plotRealtime.setChecked(True) self._ui.radioButton_plotRealtime.toggled.connect(self.changePlotOption) #For plotting calibration data: grid = Qwt5.QwtPlotGrid() canvas = self._ui.qwtPlot.canvas().setLineWidth(2) pen = QtGui.QPen(QtCore.Qt.lightGray) grid.setPen(pen) grid.attach(self._ui.qwtPlot) self.curve = Qwt5.QwtPlotCurve('') self.curve.setPen(pen) self.curve.attach(self._ui.qwtPlot) self.useFeedback = False # A timer to update: self._updater = QtCore.QTimer() self._updater.timeout.connect(self.updateData) #self._updater.start(100) self.monitor = None self.errmon = None
def on_show(self): self.plot.clear() self.plot.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->') self.plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->') grid = Qwt.QwtPlotGrid() pen = QPen(Qt.DotLine) pen.setColor(Qt.black) pen.setWidth(0) grid.setPen(pen) grid.attach(self.plot) has_series = False coloriter = iter(COLORS) for row in range(self.series_list_model.rowCount()): model_index = self.series_list_model.index(row, 0) checked = self.series_list_model.data( model_index, Qt.CheckStateRole) == QVariant(Qt.Checked) name = str(self.series_list_model.data(model_index).toString()) if checked: has_series = True x_from = self.from_spin.value() x_to = self.to_spin.value() series = self.data.get_series_data(name)[x_from:x_to + 1] color = QColor(coloriter.next()) curve = Qwt.QwtPlotCurve(name) pen = QPen(color) pen.setWidth(2) curve.setPen(pen) curve.setData(range(len(series)), series) curve.setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, QBrush(color), QPen(color), QSize(5, 5))) curve.attach(self.plot) if has_series and self.legend_cb.isChecked(): self.plot.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend) else: self.plot.insertLegend(None) self.plot.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 initialize_plots(self): # Create time series plot self.plot_ts = self.ui.plot_ts self.plot_ts.setCanvasBackground(Qt.white) font = QtGui.QFont("default", pointSize=10) label = Qwt.QwtText("Elevation (m)") label.setFont(font) self.plot_ts.setAxisTitle(0, label) label.setText("Time (s)") self.plot_ts.setAxisTitle(2, label) self.grid = Qwt.QwtPlotGrid() self.grid.attach(self.plot_ts) self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) self.curve_ts = Qwt.QwtPlotCurve('') self.curve_ts.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) self.pen = QPen(QColor('black')) self.pen.setWidth(1.5) self.curve_ts.setPen(self.pen) self.curve_ts.attach(self.plot_ts) # Create output spectrum plot self.plot_spec = self.ui.plot_spec self.plot_spec.setCanvasBackground(Qt.white) label.setText("Spectral density") self.plot_spec.setAxisTitle(0, label) label.setText("Frequency (Hz)") self.plot_spec.setAxisTitle(2, label) self.grid = Qwt.QwtPlotGrid() self.grid.attach(self.plot_spec) self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) self.curve_spec = Qwt.QwtPlotCurve('') self.curve_spec.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) self.pen = QPen(QColor('black')) self.pen.setWidth(1.5) self.curve_spec.setPen(self.pen) self.curve_spec.attach(self.plot_spec)
def create_plot(self): self.qwtPlot.setCanvasBackground(Qt.white) self.qwtPlot.setAxisTitle(self.qwtPlot.xBottom, 'Longitude') self.qwtPlot.setAxisTitle(self.qwtPlot.yLeft, 'Latitude') grid = Qwt.QwtPlotGrid() grid.attach(self.qwtPlot) self.qwtPlot.replot() self.curve = [None]*3 pen = [ QPen(QColor('red')) ,QPen(QColor('black')), QPen(QColor('blue')) ] for i in range(3): self.curve[i] = Qwt.QwtPlotCurve('') self.curve[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) pen[i].setWidth(2) self.curve[i].setPen(pen[i]) self.curve[i].attach(self.qwtPlot)
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, parent=None): PyQwt.QwtPlot.__init__(self, parent) self.setCanvasBackground(self.ColorBackground) grid = PyQwt.QwtPlotGrid() #grid.enableX(False) grid.setMajPen(QtGui.QPen(QtCore.Qt.lightGray, 0, QtCore.Qt.DashLine)) grid.attach(self) self._curve = PyQwt.QwtPlotCurve("Curve") self._curve.setRenderHint(self._curve.RenderAntialiased) # try to find reasonable width for the graph line #w = QtGui.QFontMetrics(QtGui.QApplication.font()).lineWidth() w = 2 pen = QtGui.QPen(self.ColorCurve, w) pen.setCosmetic(False) self._curve.setPen(pen) self._curve.attach(self)
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) self.ymax = 0 self.xmax = 0 self.ymin = 0 self.xmin = 0 self.setCanvasColor(Qt.Qt.darkCyan) grid = Qwt.QwtPlotGrid() grid.attach(self) grid.setMajPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.DotLine)) self.setAxisScale(Qwt.QwtPlot.xBottom, -3, 3) self.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2) self.drawUnitcircle()
def make(): demo = Qwt.QwtPlot() demo.setTitle('Symbols Demo') curve = QwtPlotCurveSizes() curve.attach(demo) curve_a = QwtPlotCurveSizes() curve_a.attach(demo) # need to create a default symbol for the curves due to inner # workings of QwtCurve curve.setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.black), Qt.QPen(Qt.Qt.black), Qt.QSize(5, 5))) curve.setPen(Qt.QPen(Qt.Qt.blue, 2)) curve_a.setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.black), Qt.QPen(Qt.Qt.black), Qt.QSize(5, 5))) curve_a.setPen(Qt.QPen(Qt.Qt.blue, 2)) # create some data x_array = numpy.zeros(20, numpy.float32) y_array = numpy.zeros(20, numpy.float32) symbol_sizes = numpy.zeros(20, numpy.int32) symbolList = [] for i in range(20): x_array[i] = 1.0 * i y_array[i] = 2.0 * i symbol_sizes[i] = 3 + i if i % 2 == 0: symbolList.append( Qwt.QwtSymbol(Qwt.QwtSymbol.UTriangle, Qt.QBrush(Qt.Qt.black), Qt.QPen(Qt.Qt.black), Qt.QSize(3 + i, 3 + i))) else: symbolList.append( Qwt.QwtSymbol(Qwt.QwtSymbol.DTriangle, Qt.QBrush(Qt.Qt.red), Qt.QPen(Qt.Qt.red), Qt.QSize(3 + i, 3 + i))) curve.setData(x_array, y_array, symbol_sizes) x_array = x_array + 10 curve_a.setData(x_array, y_array) curve_a.setSymbolList(symbolList) grid = Qwt.QwtPlotGrid() grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)) grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine)) grid.attach(demo) demo.replot() return demo
def __init__(self, *args): Qwt.QwtPlot.__init__(self, *args) self.curves = {} self.data = {} self.timeData = 1.0 * arange(0, HISTORY, 1) self.setAutoReplot(False) self.plotLayout().setAlignCanvasToScales(True) self.setAxisScale(Qwt.QwtPlot.xBottom, HISTORY, 0) self.setAxisScale(Qwt.QwtPlot.yLeft, 0, 100) self.setAxisLabelAlignment( Qwt.QwtPlot.xBottom, Qt.Qt.AlignLeft | Qt.Qt.AlignBottom) grid = Qwt.QwtPlotGrid() grid.enableXMin(True) grid.enableYMin(True) grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine)); grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0 , Qt.Qt.DotLine)); grid.attach(self) stat = MemoryStat.statistic() self.data["MemTotal"] = zeros(HISTORY, float) self.data["MemFree"] = zeros(HISTORY, float) self.data["SwapTotal"] = zeros(HISTORY, float) self.data["SwapFree"] = zeros(HISTORY, float) curve = MemoryCurve("Memory") curve.setColor(self.colors[0]) curve.attach(self) self.curves["Memory"] = curve self.data["Memory"] = zeros(HISTORY, float) curve = MemoryCurve("Swap") curve.setColor(self.colors[1]) curve.attach(self) self.curves["Swap"] = curve self.data["Swap"] = zeros(HISTORY, float) self.startTimer(1000) self.replot()