class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() self.current_y = 0 self.timer = QtCore.QTimer() self.timer.timeout.connect(self.update_plot) self.timer.setInterval(1000/FREQ) self.timer.start() def initUI(self): self.setGeometry(300, 300, 1000, 1000) self.setWindowTitle('Icon') self.setWindowIcon(QtGui.QIcon('web.png')) self.plot = QwtPlot("Test", self) self.plot.resize(900, 900) self.curve = QwtPlotCurve("Curve 1") self.curve.attach(self.plot) self.show() def update_plot(self): self.curve.setData(x, ys[self.current_y]) self.current_y = (self.current_y + 1) % YS
def __init__(self, *args): QMainWindow.__init__(self, *args) self.plot = QwtPlot(self) self.plot.setTitle("A Simple Map Demonstration") self.plot.setCanvasBackground(Qt.white) self.plot.setAxisTitle(QwtPlot.xBottom, "x") self.plot.setAxisTitle(QwtPlot.yLeft, "y") self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0) self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0) self.setCentralWidget(self.plot) # Initialize map data self.count = self.i = 1000 self.xs = np.zeros(self.count, np.float) self.ys = np.zeros(self.count, np.float) self.kappa = 0.2 self.curve = QwtPlotCurve("Map") self.curve.attach(self.plot) self.curve.setSymbol( QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.blue), QSize(5, 5))) self.curve.setPen(QPen(Qt.cyan)) toolBar = QToolBar(self) self.addToolBar(toolBar) # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz) self.ticks = 10 self.tid = self.startTimer(self.ticks) self.timer_tic = None self.user_tic = None self.system_tic = None self.plot.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.white) curva = QwtPlotCurve('Altitud') self.phase=0 ################################################## # Initialize data self.x = [0] self.y = [0] # Title of the graph self.g1title = "Altitude= " + str(self.x[0]) self.insertLegend(QwtLegend(), QwtPlot.BottomLegend); self.curveR = QwtPlotCurve("Altitude") self.curveR.attach(self) self.curveR.setPen(QPen(Qt.blue)) self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)") self.setAxisTitle(QwtPlot.yLeft, "Altitude(m)") self.setAxisScale(QwtPlot.xBottom, 0.0, 20) self.setAxisScale(QwtPlot.yLeft, 0.0, 20) self.pal = QPalette() #####palette for background self.pal.setColor(QPalette.Text, Qt.white) self.pal.setColor(QPalette.Foreground, Qt.white) self.setPalette(self.pal) self.counter=0 ###counter for actualize data, is the same for all of the graphs/data grid = QwtPlotGrid() grid.attach(self) grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
def make(): # create a plot with a white canvas demo = QwtPlot(QwtText("Errorbar Demonstation")) demo.setCanvasBackground(Qt.white) demo.plotLayout().setAlignCanvasToScales(True) grid = QwtPlotGrid() grid.attach(demo) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # calculate data and errors for a curve with error bars x = np.arange(0, 10.1, 0.5, np.float) y = np.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=QPen(Qt.black, 2), curveSymbol=QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.black, 2), QSize(9, 9)), errorPen=QPen(Qt.blue, 2), errorCap=10, errorOnTop=errorOnTop, ) curve.attach(demo) demo.resize(640, 480) demo.show() return demo
class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() self.current_y = 0 self.timer = QtCore.QTimer() self.timer.timeout.connect(self.update_plot) self.timer.setInterval(1000 / FREQ) self.timer.start() def initUI(self): self.setGeometry(300, 300, 1000, 1000) self.setWindowTitle('Icon') self.setWindowIcon(QtGui.QIcon('web.png')) self.plot = QwtPlot("Test", self) self.plot.resize(900, 900) self.curve = QwtPlotCurve("Curve 1") self.curve.attach(self.plot) self.show() def update_plot(self): self.curve.setData(x, ys[self.current_y]) self.current_y = (self.current_y + 1) % YS
def __init__(self, N): QwtPlot.__init__(self) self.setTitle('X-Y Signals') grid = QwtPlotGrid() pen = QPen(Qt.black, 0, Qt.DashDotLine) grid.setPen(pen) grid.attach(self)
def __init__(self, *args): colors = [ Qt.red, Qt.darkRed, Qt.green, Qt.darkGreen, Qt.blue, Qt.darkBlue, Qt.cyan, Qt.darkCyan, Qt.magenta, Qt.darkMagenta, Qt.yellow, Qt.darkYellow, Qt.gray, Qt.darkGray, Qt.lightGray, Qt.black ] QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.white) self.alignScales() # grid self.grid = QwtPlotGrid() self.grid.attach(self) self.grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # set titles self.setTitle("Gráfico") self.setAxisTitle(QwtPlot.xBottom, 'Tempo [hh:mm:ss] -->') self.setAxisTitle(QwtPlot.yLeft, 'Nível [mm] -->') """Habilita e denomina eixo Y2""" self.enableAxis(QwtPlot.yRight) self.setAxisTitle(QwtPlot.yRight, '<-- Temp. [ºC]') self.nplots = 16 self.Plots = np.array([]) self.Data = np.array([]) for i in range(self.nplots): self.Plots = np.append(self.Plots, QwtPlotCurve()) self.Plots[i].setPen(QPen(colors[i])) self.Plots[i].attach(self) """define como valor plotado será escrito no eixo x""" self.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw()) self.Data = np.append(self.Data, dataclass()) """Os índices pares se referem à plots no eixo Y1, e os índices ímpares são ligados ao eixo Y2""" if divmod(i, 2)[1] == 1: self.Plots[i].setYAxis(QwtPlot.yRight) self.Plots[i].setData(self.Data[i].x, self.Data[i].y) # legend #self.legend = QwtLegend #QwtLegend().setFrameStyle(QFrame.Box) #self.insertLegend(QwtLegend().setFrameStyle(QFrame.Box), QwtPlot.BottomLegend) self.insertLegend(QwtLegend(), QwtPlot.BottomLegend) # replot self.replot() # zoom # self.zoomer = QwtPlotZoomer(QwtPlot.xBottom, # QwtPlot.yLeft, # QwtPicker.DragSelection, # QwtPicker.AlwaysOn, # self.canvas()) # # self.zoomer.setRubberBandPen(QPen(Qt.green)) self.startTimer(50)
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle('Cartesian Coordinate System Demo') # create a plot with a white canvas self.setCanvasBackground(Qt.white) # set plot layout self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # attach a grid grid = QwtPlotGrid() grid.attach(self) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # attach a x-axis xaxis = CartesianAxis(QwtPlot.xBottom, QwtPlot.yLeft) xaxis.attach(self) self.enableAxis(QwtPlot.xBottom, False) # attach a y-axis yaxis = CartesianAxis(QwtPlot.yLeft, QwtPlot.xBottom) yaxis.attach(self) self.enableAxis(QwtPlot.yLeft, False) # calculate 3 NumPy arrays x = np.arange(-2*np.pi, 2*np.pi, 0.01) y = np.pi*np.sin(x) z = 4*np.pi*np.cos(x)*np.cos(x)*np.sin(x) # attach a curve curve = QwtPlotCurve('y = pi*sin(x)') curve.attach(self) curve.setPen(QPen(Qt.green, 2)) curve.setData(x, y) # attach another curve curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2') curve.attach(self) curve.setPen(QPen(Qt.black, 2)) curve.setData(x, z) self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle("Cartesian Coordinate System Demo") # create a plot with a white canvas self.setCanvasBackground(Qt.white) # set plot layout self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # attach a grid grid = QwtPlotGrid() grid.attach(self) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # attach a x-axis xaxis = CartesianAxis(QwtPlot.xBottom, QwtPlot.yLeft) xaxis.attach(self) self.enableAxis(QwtPlot.xBottom, False) # attach a y-axis yaxis = CartesianAxis(QwtPlot.yLeft, QwtPlot.xBottom) yaxis.attach(self) self.enableAxis(QwtPlot.yLeft, False) # calculate 3 NumPy arrays x = np.arange(-2 * np.pi, 2 * np.pi, 0.01) y = np.pi * np.sin(x) z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x) # attach a curve curve = QwtPlotCurve("y = pi*sin(x)") curve.attach(self) curve.setPen(QPen(Qt.green, 2)) curve.setData(x, y) # attach another curve curve = QwtPlotCurve("y = 4*pi*sin(x)*cos(x)**2") curve.attach(self) curve.setPen(QPen(Qt.black, 2)) curve.setData(x, z) self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.white) self.alignScales() # Initialize data self.x = np.arange(0.0, 100.1, 0.5) self.y = np.zeros(len(self.x), np.float) self.z = np.zeros(len(self.x), np.float) self.setTitle("A Moving QwtPlot Demonstration") self.insertLegend(QwtLegend(), QwtPlot.BottomLegend) self.curveR = QwtPlotCurve("Data Moving Right") self.curveR.attach(self) self.curveL = QwtPlotCurve("Data Moving Left") self.curveL.attach(self) self.curveL.setSymbol(QwtSymbol(QwtSymbol.Ellipse, QBrush(), QPen(Qt.yellow), QSize(7, 7))) self.curveR.setPen(QPen(Qt.red)) self.curveL.setPen(QPen(Qt.blue)) mY = QwtPlotMarker() mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) mY.setLineStyle(QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)") self.setAxisTitle(QwtPlot.yLeft, "Values") self.startTimer(50) self.phase = 0.0
def createGraph(self): self.plot = QwtPlot() self.plot.resize(1000, 1000) self.plot.setAxisScaleDraw(QwtPlot.xBottom, DateTimeTimeScaleDraw(names=False)) self.plot.replot() self.plot.show()
def __init__(self, N): QwtPlot.__init__(self) self.setTitle('Time signals') self.setCanvasBackground(QBrush(QColor(COL, COL, COL))) grid = QwtPlotGrid() pen = QPen(Qt.black, 0, Qt.DashDotLine) grid.setPen(pen) grid.attach(self)
def initUI(self): self.setGeometry(300, 300, 1000, 1000) self.setWindowTitle('Icon') self.setWindowIcon(QtGui.QIcon('web.png')) self.plot = QwtPlot("Test", self) self.plot.resize(900, 900) self.curve = QwtPlotCurve("Curve 1") self.curve.attach(self.plot) self.show()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle("Interactive Plot") self.setCanvasColor(Qt.darkCyan) grid = QwtPlotGrid() grid.attach(self) grid.setMajorPen(QPen(Qt.white, 0, Qt.DotLine)) self.setAxisScale(QwtPlot.xBottom, 0.0, 100.0) self.setAxisScale(QwtPlot.yLeft, 0.0, 100.0) # Avoid jumping when label with 3 digits # appear/disappear when scrolling vertically scaleDraw = self.axisScaleDraw(QwtPlot.yLeft) scaleDraw.setMinimumExtent( scaleDraw.extent(self.axisWidget(QwtPlot.yLeft).font()) ) self.plotLayout().setAlignCanvasToScales(True) self.__insertCurve(Qt.Vertical, Qt.blue, 30.0) self.__insertCurve(Qt.Vertical, Qt.magenta, 70.0) self.__insertCurve(Qt.Horizontal, Qt.yellow, 30.0) self.__insertCurve(Qt.Horizontal, Qt.white, 70.0) self.replot() scaleWidget = self.axisWidget(QwtPlot.yLeft) scaleWidget.setMargin(10) self.__colorBar = ColorBar(Qt.Vertical, scaleWidget) self.__colorBar.setRange(QColor(Qt.red), QColor(Qt.darkBlue)) self.__colorBar.setFocusPolicy(Qt.TabFocus) self.__colorBar.colorSelected.connect(self.setCanvasColor) # we need the resize events, to lay out the color bar scaleWidget.installEventFilter(self) # we need the resize events, to lay out the wheel self.canvas().installEventFilter(self) scaleWidget.setWhatsThis( "Selecting a value at the scale will insert a new curve." ) self.__colorBar.setWhatsThis( "Selecting a color will change the background of the plot." ) self.axisWidget(QwtPlot.xBottom).setWhatsThis( "Selecting a value at the scale will insert a new curve." )
def __init__(self, *args): QwtPlot.__init__(self, *args) # Initialize Decice address, #self.uut_dev = GPIBdevice.GPIBdevice(args[0]) self.rm = visa.ResourceManager() print(self.rm.list_resources()) self.uut_dev = self.rm.open_resource(args[0]) print('open pass') # Initialize 坐标轴 self.setCanvasBackground(Qt.white) self.alignScales() grid = QwtPlotGrid() grid.attach(self) grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine)) self.setAxisScale(QwtPlot.xBottom, 0.0, 300.1, 10.0) self.setAxisAutoScale(QwtPlot.yLeft, True) #self.setAxisScale(QwtPlot.yLeft,4.0,20.0,2.0) self.x = np.arange( 0.0, 300.1, 0.5 ) #0.25 for ONE POINT, THIS SHOULD BE Align to the reading rate:250ms self.z = np.zeros(len(self.x), np.float) self.setTitle("UUT Reading Monitor") self.insertLegend(QwtLegend(), QwtPlot.RightLegend) self.curveL = QwtPlotCurve("UUT Reading") self.curveL.attach(self) self.curveL.setPen(QPen(Qt.red)) self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)") self.setAxisTitle(QwtPlot.yLeft, "UUT - Reading") self.replot() self.startTimer(500) #ms# FOR GET READING self.starttime = time.clock() #unit: s self.idx = 0 self.readfmt = "%.8f" self.Saveinfo("Starting...") IDN = self.uut_get_val(self.uut_dev, "*IDN?\r") print IDN print "Starting..."
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle("Interactive Plot") self.setCanvasColor(Qt.darkCyan) grid = QwtPlotGrid() grid.attach(self) grid.setMajorPen(QPen(Qt.white, 0, Qt.DotLine)) self.setAxisScale(QwtPlot.xBottom, 0.0, 100.0) self.setAxisScale(QwtPlot.yLeft, 0.0, 100.0) # Avoid jumping when label with 3 digits # appear/disappear when scrolling vertically scaleDraw = self.axisScaleDraw(QwtPlot.yLeft) scaleDraw.setMinimumExtent(scaleDraw.extent( self.axisWidget(QwtPlot.yLeft).font())) self.plotLayout().setAlignCanvasToScales(True) self.__insertCurve(Qt.Vertical, Qt.blue, 30.0) self.__insertCurve(Qt.Vertical, Qt.magenta, 70.0) self.__insertCurve(Qt.Horizontal, Qt.yellow, 30.0) self.__insertCurve(Qt.Horizontal, Qt.white, 70.0) self.replot() scaleWidget = self.axisWidget(QwtPlot.yLeft) scaleWidget.setMargin(10) self.__colorBar = ColorBar(Qt.Vertical, scaleWidget) self.__colorBar.setRange( QColor(Qt.red), QColor(Qt.darkBlue)) self.__colorBar.setFocusPolicy(Qt.TabFocus) self.__colorBar.colorSelected.connect(self.setCanvasColor) # we need the resize events, to lay out the color bar scaleWidget.installEventFilter(self) # we need the resize events, to lay out the wheel self.canvas().installEventFilter(self) scaleWidget.setWhatsThis( 'Selecting a value at the scale will insert a new curve.') self.__colorBar.setWhatsThis( 'Selecting a color will change the background of the plot.') self.axisWidget(QwtPlot.xBottom).setWhatsThis( 'Selecting a value at the scale will insert a new curve.')
def __init__(self, *args): QwtPlot.__init__(self, *args) # make a QwtPlot widget self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(1) self.setTitle('QwtImagePlot: (un)zoom & (un)hide') # set axis titles self.setAxisTitle(QwtPlot.xBottom, 'time (s)') self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)') # insert a few curves self.cSin = QwtPlotCurve('y = pi*sin(x)') self.cCos = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2') self.cSin.attach(self) self.cCos.attach(self) # set curve styles self.cSin.setPen(QPen(Qt.green, 2)) self.cCos.setPen(QPen(Qt.black, 2)) self.xzoom_loc = None self.yzoom_loc = None self.xpos = None self.ypos = None # attach a grid grid = QwtPlotGrid() grid.attach(self) grid.setPen(Qt.black, 0, Qt.DotLine) # create zoom curve self.zoom_outline = QwtPlotCurve() self.zoom_outline.setStyle(QwtPlotCurve.Lines) # create and initialize an image display self.plotImage = QwtPlotImage(self) self.plotImage.attach(self) self.gain = 2.0 self.updateDisplay() self.zoomStack = [] self.spy = Spy(self.canvas()) self.prev_xpos = None self.prev_ypos = None # self.connect(self, Qt.SIGNAL("legendClicked(QwtPlotItem*)"), # self.toggleVisibility) self.spy.MouseMove.connect(self.onmouseMoveEvent) self.spy.MousePress.connect(self.onmousePressEvent) self.spy.MouseRelease.connect(self.onmouseReleaseEvent)
def __init__(self, *args): QwtPlot.__init__(self, *args) self.insertLegend(QwtLegend(), QwtPlot.RightLegend) self.enableAxis(self.xBottom) # insert a few curves self.Reward = QwtPlotCurve('Reward') self.Reward.setPen(QPen(Qt.darkGreen)) self.Reward.attach(self) # initialize the data self.Reward.setData([0], [0]) # replot self.replot()
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.qwtPlot = QwtPlot(self.centralwidget) self.qwtPlot.setObjectName(_fromUtf8("qwtPlot")) self.verticalLayout.addWidget(self.qwtPlot) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.measureButton = QtGui.QPushButton(self.centralwidget) self.measureButton.setObjectName(_fromUtf8("measureButton")) self.horizontalLayout.addWidget(self.measureButton) self.closeButton = QtGui.QPushButton(self.centralwidget) self.closeButton.setObjectName(_fromUtf8("closeButton")) self.horizontalLayout.addWidget(self.closeButton) self.verticalLayout.addLayout(self.horizontalLayout) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 30)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, *args): QMainWindow.__init__(self, *args) self.plot = QwtPlot(self) self.plot.setTitle("A Simple Map Demonstration") self.plot.setCanvasBackground(Qt.white) self.plot.setAxisTitle(QwtPlot.xBottom, "x") self.plot.setAxisTitle(QwtPlot.yLeft, "y") self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0) self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0) self.setCentralWidget(self.plot) # Initialize map data self.count = self.i = 1000 self.xs = np.zeros(self.count, np.float) self.ys = np.zeros(self.count, np.float) self.kappa = 0.2 self.curve = QwtPlotCurve("Map") self.curve.attach(self.plot) self.curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.blue), QSize(5, 5))) self.curve.setPen(QPen(Qt.cyan)) toolBar = QToolBar(self) self.addToolBar(toolBar) # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz) self.ticks = 10 self.tid = self.startTimer(self.ticks) self.timer_tic = None self.user_tic = None self.system_tic = None self.plot.replot()
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.qwtPlot = QwtPlot(self.centralwidget) self.qwtPlot.setObjectName(_fromUtf8("qwtPlot")) self.verticalLayout.addWidget(self.qwtPlot) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.measureButton = QtGui.QPushButton(self.centralwidget) self.measureButton.setObjectName(_fromUtf8("measureButton")) self.horizontalLayout.addWidget(self.measureButton) self.saveButton = QtGui.QPushButton(self.centralwidget) self.saveButton.setEnabled(False) self.saveButton.setObjectName(_fromUtf8("saveButton")) self.horizontalLayout.addWidget(self.saveButton) self.lineEdit = QtGui.QLineEdit(self.centralwidget) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.horizontalLayout.addWidget(self.lineEdit) self.closeButton = QtGui.QPushButton(self.centralwidget) self.closeButton.setObjectName(_fromUtf8("closeButton")) self.horizontalLayout.addWidget(self.closeButton) self.verticalLayout.addLayout(self.horizontalLayout) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 30)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.measureButton.setText(_translate("MainWindow", "Measure", None)) self.saveButton.setText(_translate("MainWindow", "Save to file:", None)) self.lineEdit.setText(_translate("MainWindow", "data.csv", None)) self.closeButton.setText(_translate("MainWindow", "Close", None))
def __init__(self, *args): QwtPlot.__init__(self, *args) self.curves = {} self.data = {} self.timeData = 1.0 * np.arange(0, HISTORY, 1) self.MemStat = MemStat() self.setAutoReplot(False) self.plotLayout().setAlignCanvasToScales(True) self.setAxisScale(QwtPlot.xBottom, HISTORY, 0) self.setAxisScale(QwtPlot.yLeft, 0, 100) self.setAxisLabelAlignment(QwtPlot.xBottom, Qt.AlignLeft | Qt.AlignBottom) grid = QwtPlotGrid() grid.enableXMin(True) grid.enableYMin(True) grid.setMajPen(QPen(Qt.black, 0, Qt.DotLine)) grid.setMinPen(QPen(Qt.gray, 0, Qt.DotLine)) grid.attach(self) stat = MemStat.statistic() self.data["MemTotal"] = np.zeros(HISTORY, float) self.data["MemFree"] = np.zeros(HISTORY, float) self.data["SwapTotal"] = np.zeros(HISTORY, float) self.data["SwapFree"] = np.zeros(HISTORY, float) curve = MemoryCurve("Memory") curve.setColor(self.colors[0]) curve.attach(self) self.curves["Memory"] = curve self.data["Memory"] = np.zeros(HISTORY, float) curve = MemoryCurve("Swap") curve.setColor(self.colors[1]) curve.attach(self) self.curves["Swap"] = curve self.data["Swap"] = np.zeros(HISTORY, float) self.startTimer(1000) self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle("Cartesian Coordinate System Demo") # create a plot with a white canvas self.setCanvasBackground(Qt.white) # set plot layout self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # attach a grid QwtPlotGrid.make(self, color=Qt.lightGray, width=0, style=Qt.DotLine, z=-1) # attach a x-axis xaxis = CartesianAxis(QwtPlot.xBottom, QwtPlot.yLeft) xaxis.attach(self) self.enableAxis(QwtPlot.xBottom, False) # attach a y-axis yaxis = CartesianAxis(QwtPlot.yLeft, QwtPlot.xBottom) yaxis.attach(self) self.enableAxis(QwtPlot.yLeft, False) # calculate 3 NumPy arrays x = np.arange(-2 * np.pi, 2 * np.pi, 0.01) # attach a curve QwtPlotCurve.make( x, np.pi * np.sin(x), title="y = pi*sin(x)", linecolor=Qt.green, linewidth=2, plot=self, antialiased=True, ) # attach another curve QwtPlotCurve.make( x, 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x), title="y = 4*pi*sin(x)*cos(x)**2", linecolor=Qt.blue, linewidth=2, plot=self, antialiased=True, ) self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.insertLegend(QwtLegend(), QwtPlot.RightLegend) self.enableAxis(self.xBottom) # insert a few curves self.Alpha = QwtPlotCurve('Alpha') self.Alpha.setPen(QPen(Qt.red)) self.Alpha.attach(self) self.Epsilon = QwtPlotCurve('Epsilon') self.Epsilon.setPen(QPen(Qt.blue)) self.Epsilon.attach(self) # initialize the data self.Alpha.setData([0], [0]) self.Epsilon.setData([0], [0]) # replot self.replot()
def eventFilter(self, object, event): if event.type() == QEvent.Resize: size = event.size() if object == self.axisWidget(QwtPlot.yLeft): margin = 2 x = size.width() - object.margin() + margin w = object.margin() - 2 * margin y = object.startBorderDist() h = size.height() - object.startBorderDist() - object.endBorderDist() self.__colorBar.setGeometry(x, y, w, h) return QwtPlot.eventFilter(self, object, event)
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle('ReallySimpleDemo.py') self.insertLegend(QwtLegend(), QwtPlot.RightLegend) self.setAxisTitle(QwtPlot.xBottom, 'x -->') self.setAxisTitle(QwtPlot.yLeft, 'y -->') self.enableAxis(self.xBottom) # insert a few curves cSin = QwtPlotCurve('y = sin(x)') cSin.setPen(QPen(Qt.red)) cSin.attach(self) cCos = QwtPlotCurve('y = cos(x)') cCos.setPen(QPen(Qt.blue)) cCos.attach(self) # make a Numeric array for the horizontal data x = np.arange(0.0, 10.0, 0.1) # initialize the data cSin.setData(x, np.sin(x)) cCos.setData(x, np.cos(x)) # insert a horizontal marker at y = 0 mY = QwtPlotMarker() mY.setLabel(QwtText('y = 0')) mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) mY.setLineStyle(QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) # insert a vertical marker at x = 2 pi mX = QwtPlotMarker() mX.setLabel(QwtText('x = 2 pi')) mX.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) mX.setLineStyle(QwtPlotMarker.VLine) mX.setXValue(2*np.pi) mX.attach(self) # replot self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle('ReallySimpleDemo.py') self.insertLegend(QwtLegend(), QwtPlot.RightLegend) self.setAxisTitle(QwtPlot.xBottom, 'x -->') self.setAxisTitle(QwtPlot.yLeft, 'y -->') self.enableAxis(self.xBottom) # insert a few curves cSin = QwtPlotCurve('y = sin(x)') cSin.setPen(QPen(Qt.red)) cSin.attach(self) cCos = QwtPlotCurve('y = cos(x)') cCos.setPen(QPen(Qt.blue)) cCos.attach(self) # make a Numeric array for the horizontal data x = np.arange(0.0, 10.0, 0.1) # initialize the data cSin.setData(x, np.sin(x)) cCos.setData(x, np.cos(x)) # insert a horizontal marker at y = 0 mY = QwtPlotMarker() mY.setLabel(QwtText('y = 0')) mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) mY.setLineStyle(QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) # insert a vertical marker at x = 2 pi mX = QwtPlotMarker() mX.setLabel(QwtText('x = 2 pi')) mX.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) mX.setLineStyle(QwtPlotMarker.VLine) mX.setXValue(2 * np.pi) mX.attach(self) # replot self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) global x, y, lineL, lineH, curveTemp HISTORY = 300 x = 0.1 * np.arange(0, -HISTORY, -1) y = np.zeros(HISTORY, np.float) self.setAxisScale(QwtPlot.yLeft, 0, 100) lineL = QwtPlotMarker() lineL.setLinePen(QtGui.QPen(QtCore.Qt.blue)) lineL.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom) lineL.setLineStyle(QwtPlotMarker.HLine) lineL.setYValue(0) lineL.attach(self) lineH = QwtPlotMarker() lineH.setLinePen(QtGui.QPen(QtCore.Qt.red)) lineH.setLabelAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop) lineH.setLineStyle(QwtPlotMarker.HLine) lineH.setYValue(100) lineH.attach(self) curveTemp = QwtPlotCurve("实时温度") curveTemp.attach(self)
def eventFilter(self, object, event): if event.type() == QEvent.Resize: size = event.size() if object == self.axisWidget(QwtPlot.yLeft): margin = 2 x = size.width() - object.margin() + margin w = object.margin() - 2 * margin y = object.startBorderDist() h = (size.height() - object.startBorderDist() - object.endBorderDist()) self.__colorBar.setGeometry(x, y, w, h) return QwtPlot.eventFilter(self, object, event)
def main(args): app = QApplication(args) demo = QwtPlot() grid = QwtPlotGrid() grid.attach(demo) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) grid.enableX(True) grid.enableY(True) complex_divider = 50.0 myXScale = ComplexScaleDraw(start_value=0.0, end_value=complex_divider) #print('myXScale', myXScale) demo.setAxisScaleDraw(QwtPlot.xBottom, myXScale) m = QwtPlotMarker() m.attach(demo) m.setValue(complex_divider, 0.0) m.setLineStyle(QwtPlotMarker.VLine) m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) m.setLinePen(QPen(Qt.black, 2, Qt.SolidLine)) vector_array = numpy.zeros((100, ), numpy.float32) for i in range(100): vector_array[i] = i curve = QwtPlotCurve('example data') curve.attach(demo) x_array = numpy.zeros(100, numpy.float32) y_array = numpy.zeros(100, numpy.float32) for i in range(100): x_array[i] = 1.0 * i y_array[i] = 2.0 * i curve.setSamples(x_array, y_array) demo.resize(600, 400) demo.replot() demo.show() # app.setMainWidget(demo) app.exec_()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.white) # Initialize data self.x = [0] self.y = [0] self.setTitle("A Moving QwtPlot Demonstration") self.insertLegend(QwtLegend(), QwtPlot.BottomLegend); self.curveR = QwtPlotCurve("Data Moving Right") self.curveR.attach(self) self.curveR.setPen(QPen(Qt.red)) self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)") self.setAxisTitle(QwtPlot.yLeft, "Values") self.startTimer(400) self.phase = 0.0
def eventFilter(self, object, event): if event.type() == QEvent.FocusIn: self.__showCursor(True) if event.type() == QEvent.FocusOut: self.__showCursor(False) if event.type() == QEvent.Paint: QApplication.postEvent(self, QEvent(QEvent.User)) elif event.type() == QEvent.MouseButtonPress: self.__select(event.pos()) return True elif event.type() == QEvent.MouseMove: self.__move(event.pos()) return True if event.type() == QEvent.KeyPress: delta = 5 key = event.key() if key == Qt.Key_Up: self.__shiftCurveCursor(True) return True elif key == Qt.Key_Down: self.__shiftCurveCursor(False) return True elif key == Qt.Key_Right or key == Qt.Key_Plus: if self.__selectedCurve: self.__shiftPointCursor(True) else: self.__shiftCurveCursor(True) return True elif key == Qt.Key_Left or key == Qt.Key_Minus: if self.__selectedCurve: self.__shiftPointCursor(False) else: self.__shiftCurveCursor(True) return True if key == Qt.Key_1: self.__moveBy(-delta, delta) elif key == Qt.Key_2: self.__moveBy(0, delta) elif key == Qt.Key_3: self.__moveBy(delta, delta) elif key == Qt.Key_4: self.__moveBy(-delta, 0) elif key == Qt.Key_6: self.__moveBy(delta, 0) elif key == Qt.Key_7: self.__moveBy(-delta, -delta) elif key == Qt.Key_8: self.__moveBy(0, -delta) elif key == Qt.Key_9: self.__moveBy(delta, -delta) return QwtPlot.eventFilter(self.__plot, object, event)
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setCanvasBackground(Qt.white) self.alignScales() # Initialize data self.x = np.arange(0.0, 100.1, 0.5) self.y = np.zeros(len(self.x), np.float) self.z = np.zeros(len(self.x), np.float) self.setTitle("A Moving QwtPlot Demonstration") self.insertLegend(QwtLegend(), QwtPlot.BottomLegend); self.curveR = QwtPlotCurve("Data Moving Right") self.curveR.attach(self) self.curveL = QwtPlotCurve("Data Moving Left") self.curveL.attach(self) self.curveL.setSymbol(QwtSymbol(QwtSymbol.Ellipse, QBrush(), QPen(Qt.yellow), QSize(7, 7))) self.curveR.setPen(QPen(Qt.red)) self.curveL.setPen(QPen(Qt.blue)) mY = QwtPlotMarker() mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) mY.setLineStyle(QwtPlotMarker.HLine) mY.setYValue(0.0) mY.attach(self) self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)") self.setAxisTitle(QwtPlot.yLeft, "Values") self.startTimer(50) self.phase = 0.0
def create_log_plot(): plot = QwtPlot('LogCurveDemo.py (or how to handle -inf values)') plot.enableAxis(QwtPlot.xBottom) plot.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine()) curve = QwtPlotCurve() curve.setRenderHint(QwtPlotCurve.RenderAntialiased) pen = QPen(Qt.magenta) pen.setWidth(1.5) curve.setPen(pen) curve.attach(plot) x = np.arange(0.0, 10.0, 0.1) y = 10 * np.cos(x)**2 - .1 print("y<=0:", y <= 0) curve.setData(x, y) plot.replot() return plot
def __init__(self, database, parent=None): super().__init__(parent) self.db = database self.updateTimer = QTimer(self) self.updateTimer.start(5000) self.plot = QwtPlot() self.curve = QwtPlotCurve() self.curve.attach(self.plot) self.plot.resize(1000, 1000) self.plot.show() self.plot.setAxisScaleDraw(QwtPlot.xBottom, DateTimeTimeScaleDraw()) axisFont = QFont("Helvetica", 11, QFont.Bold) titleFont = QFont("Helvetica", 12, QFont.Bold) xTitle = QwtText() xTitle.setText("Time") xTitle.setFont(axisFont) self.plot.setAxisTitle(self.plot.xBottom, xTitle) self.yTitle = QwtText() self.yTitle.setFont(axisFont) self.plot.setAxisTitle(self.plot.yLeft, self.yTitle) self.titleText = QwtText() self.titleText.setFont(titleFont) self.plot.setTitle(self.titleText) mainLayout = QHBoxLayout() mainLayout.addWidget(self.plot) self.setLayout(mainLayout) self.plot.show() self.results = [] self.batchID = None
def create_log_plot(): plot = QwtPlot('LogCurveDemo.py (or how to handle -inf values)') plot.enableAxis(QwtPlot.xBottom) plot.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine()) curve = QwtPlotCurve() curve.setRenderHint(QwtPlotCurve.RenderAntialiased) pen = QPen(Qt.magenta) pen.setWidth(1.5) curve.setPen(pen) curve.attach(plot) x = np.arange(0.0, 10.0, 0.1) y = 10*np.cos(x)**2-.1 print("y<=0:", y<=0) curve.setData(x, y) plot.replot() return plot
def make(): # create a plot with a white canvas demo = QwtPlot(QwtText("Errorbar Demonstation")) demo.setCanvasBackground(Qt.white) demo.plotLayout().setAlignCanvasToScales(True) grid = QwtPlotGrid() grid.attach(demo) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # calculate data and errors for a curve with error bars x = np.arange(0, 10.1, 0.5, np.float) y = np.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 = QPen(Qt.black, 2), curveSymbol = QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.black, 2), QSize(9, 9)), errorPen = QPen(Qt.blue, 2), errorCap = 10, errorOnTop = errorOnTop, ) curve.attach(demo) demo.resize(640, 480) demo.show() return demo
def make(): # create a plot with a white canvas demo = QwtPlot(QwtText("Curve Demonstation")) # demo.setCanvasBackground(Qt.white) # demo.plotLayout().setAlignCanvasToScales(True) # grid = QwtPlotGrid() # grid.attach(demo) # grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # calculate data and errors for a curve with error bars x = numpy.zeros(20, numpy.float32) y = numpy.zeros(20, numpy.float32) symbol_sizes = numpy.zeros(20, numpy.int32) symbolList = [] for i in range(20): x[i] = 1.0 * i y[i] = 2.0 * i symbol_sizes[i] = 3 + i if i % 2 == 0: symbolList.append( QwtSymbol(QwtSymbol.UTriangle, QBrush(Qt.black), QPen(Qt.black), QSize(3 + i, 3 + i))) else: symbolList.append( QwtSymbol(QwtSymbol.DTriangle, QBrush(Qt.red), QPen(Qt.red), QSize(3 + i, 3 + i))) curve = QwtPlotCurveSizes(x=x, y=y, symbolSizes=symbol_sizes) x = x + 10 curve1 = QwtPlotCurveSizes(x=x, y=y, symbolSizes=symbol_sizes) curve.setSymbol( QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.black), QPen(Qt.black), QSize(5, 5))) curve.setPen(QPen(Qt.blue, 2)) curve1.setSymbol( QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.red), QSize(10, 10))) curve1.setPen(QPen(Qt.blue, 2)) curve1.setSymbolList(symbolList) curve.attach(demo) curve1.attach(demo) demo.resize(640, 480) demo.show() return demo
def __init__(self, *args): QwtPlot.__init__(self, *args) # set plot title self.setTitle('ImagePlot') # set plot layout self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # set legend legend = QwtLegend() legend.setDefaultItemMode(QwtLegendData.Clickable) self.insertLegend(legend, QwtPlot.RightLegend) # set axis titles self.setAxisTitle(QwtPlot.xBottom, 'time (s)') self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)') colorMap = QwtLinearColorMap(Qt.blue, Qt.red) interval = QwtInterval(-1, 1) self.enableAxis(QwtPlot.yRight) self.setAxisScale(QwtPlot.yRight, -1, 1) self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True) self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap) # calculate 3 NumPy arrays x = np.arange(-2 * np.pi, 2 * np.pi, 0.01) y = np.pi * np.sin(x) z = 4 * np.pi * np.cos(x) * np.cos(x) * np.sin(x) # attach a curve curve = QwtPlotCurve('y = pi*sin(x)') curve.attach(self) curve.setPen(QPen(Qt.green, 2)) curve.setData(x, y) # attach another curve curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2') curve.attach(self) curve.setPen(QPen(Qt.black, 2)) curve.setData(x, z) # attach a grid grid = QwtPlotGrid() grid.attach(self) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # attach a horizontal marker at y = 0 marker = QwtPlotMarker() marker.attach(self) marker.setValue(0.0, 0.0) marker.setLineStyle(QwtPlotMarker.HLine) marker.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) marker.setLabel(QwtText('y = 0')) # attach a vertical marker at x = pi marker = QwtPlotMarker() marker.attach(self) marker.setValue(np.pi, 0.0) marker.setLineStyle(QwtPlotMarker.VLine) marker.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) marker.setLabel(QwtText('x = pi')) # attach a plot image plotImage = PlotImage('Image') plotImage.attach(self) plotImage.setData(square(512, -2 * np.pi, 2 * np.pi), (-2 * np.pi, 2 * np.pi), (-2 * np.pi, 2 * np.pi)) legend.SIG_CLICKED.connect(self.toggleVisibility) # replot self.replot()
class MapDemo(QMainWindow): def __init__(self, *args): QMainWindow.__init__(self, *args) self.plot = QwtPlot(self) self.plot.setTitle("A Simple Map Demonstration") self.plot.setCanvasBackground(Qt.white) self.plot.setAxisTitle(QwtPlot.xBottom, "x") self.plot.setAxisTitle(QwtPlot.yLeft, "y") self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0) self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0) self.setCentralWidget(self.plot) # Initialize map data self.count = self.i = 1000 self.xs = np.zeros(self.count, np.float) self.ys = np.zeros(self.count, np.float) self.kappa = 0.2 self.curve = QwtPlotCurve("Map") self.curve.attach(self.plot) self.curve.setSymbol( QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.blue), QSize(5, 5))) self.curve.setPen(QPen(Qt.cyan)) toolBar = QToolBar(self) self.addToolBar(toolBar) # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz) self.ticks = 10 self.tid = self.startTimer(self.ticks) self.timer_tic = None self.user_tic = None self.system_tic = None self.plot.replot() def setTicks(self, ticks): self.i = self.count self.ticks = int(ticks) self.killTimer(self.tid) self.tid = self.startTimer(ticks) def resizeEvent(self, event): self.plot.resize(event.size()) self.plot.move(0, 0) def moreData(self): if self.i == self.count: self.i = 0 self.x = random.random() self.y = random.random() self.xs[self.i] = self.x self.ys[self.i] = self.y self.i += 1 chunks = [] self.timer_toc = time.time() if self.timer_tic: chunks.append("wall: %s s." % (self.timer_toc - self.timer_tic)) print(' '.join(chunks)) self.timer_tic = self.timer_toc else: self.x, self.y = standard_map(self.x, self.y, self.kappa) self.xs[self.i] = self.x self.ys[self.i] = self.y self.i += 1 def timerEvent(self, e): self.moreData() self.curve.setData(self.xs[:self.i], self.ys[:self.i]) self.plot.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.setTitle('Frequency Response of a 2<sup>nd</sup>-order System') self.setCanvasBackground(Qt.darkBlue) # legend legend = QwtLegend() legend.setFrameStyle(QFrame.Box | QFrame.Sunken) self.insertLegend(legend, QwtPlot.BottomLegend) # grid self.grid = QwtPlotGrid() self.grid.enableXMin(True) self.grid.attach(self) # axes self.enableAxis(QwtPlot.yRight) self.setAxisTitle(QwtPlot.xBottom, '\u03c9/\u03c9<sub>0</sub>') self.setAxisTitle(QwtPlot.yLeft, 'Amplitude [dB]') self.setAxisTitle(QwtPlot.yRight, 'Phase [\u00b0]') self.setAxisMaxMajor(QwtPlot.xBottom, 6) self.setAxisMaxMinor(QwtPlot.xBottom, 10) self.setAxisScaleEngine(QwtPlot.xBottom, QwtLogScaleEngine()) # curves self.curve1 = QwtPlotCurve('Amplitude') self.curve1.setRenderHint(QwtPlotItem.RenderAntialiased); self.curve1.setPen(QPen(Qt.yellow)) self.curve1.setYAxis(QwtPlot.yLeft) self.curve1.attach(self) self.curve2 = QwtPlotCurve('Phase') self.curve2.setRenderHint(QwtPlotItem.RenderAntialiased); self.curve2.setPen(QPen(Qt.cyan)) self.curve2.setYAxis(QwtPlot.yRight) self.curve2.attach(self) # alias fn = self.fontInfo().family() # marker self.dB3Marker = m = QwtPlotMarker() m.setValue(0.0, 0.0) m.setLineStyle(QwtPlotMarker.VLine) m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) m.setLinePen(QPen(Qt.green, 2, Qt.DashDotLine)) text = QwtText('') text.setColor(Qt.green) text.setBackgroundBrush(Qt.red) text.setFont(QFont(fn, 12, QFont.Bold)) m.setLabel(text) m.attach(self) self.peakMarker = m = QwtPlotMarker() m.setLineStyle(QwtPlotMarker.HLine) m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) m.setLinePen(QPen(Qt.red, 2, Qt.DashDotLine)) text = QwtText('') text.setColor(Qt.red) text.setBackgroundBrush(QBrush(self.canvasBackground())) text.setFont(QFont(fn, 12, QFont.Bold)) m.setLabel(text) m.setSymbol(QwtSymbol(QwtSymbol.Diamond, QBrush(Qt.yellow), QPen(Qt.green), QSize(7,7))) m.attach(self) # text marker m = QwtPlotMarker() m.setValue(0.1, -20.0) m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) text = QwtText( '[1-(\u03c9/\u03c9<sub>0</sub>)<sup>2</sup>+2j\u03c9/Q]' '<sup>-1</sup>' ) text.setFont(QFont(fn, 12, QFont.Bold)) text.setColor(Qt.blue) text.setBackgroundBrush(QBrush(Qt.yellow)) text.setBorderPen(QPen(Qt.red, 2)) m.setLabel(text) m.attach(self) self.setDamp(0.01)
def __init__(self, *args): QwtPlot.__init__(self, *args) self.curves = {} self.data = {} self.timeData = 1.0 * np.arange(HISTORY-1, -1, -1) self.cpuStat = CpuStat() self.setAutoReplot(False) self.plotLayout().setAlignCanvasToScales(True) legend = QwtLegend() legend.setDefaultItemMode(QwtLegendData.Checkable) self.insertLegend(legend, QwtPlot.RightLegend) self.setAxisTitle(QwtPlot.xBottom, "System Uptime [h:m:s]") self.setAxisScaleDraw( QwtPlot.xBottom, TimeScaleDraw(self.cpuStat.upTime())) self.setAxisScale(QwtPlot.xBottom, 0, HISTORY) self.setAxisLabelRotation(QwtPlot.xBottom, -50.0) self.setAxisLabelAlignment( QwtPlot.xBottom, Qt.AlignLeft | Qt.AlignBottom) self.setAxisTitle(QwtPlot.yLeft, "Cpu Usage [%]") self.setAxisScale(QwtPlot.yLeft, 0, 100) background = Background() background.attach(self) pie = CpuPieMarker() pie.attach(self) curve = CpuCurve('System') curve.setColor(Qt.red) curve.attach(self) self.curves['System'] = curve self.data['System'] = np.zeros(HISTORY, np.float) curve = CpuCurve('User') curve.setColor(Qt.blue) curve.setZ(curve.z() - 1.0) curve.attach(self) self.curves['User'] = curve self.data['User'] = np.zeros(HISTORY, np.float) curve = CpuCurve('Total') curve.setColor(Qt.black) curve.setZ(curve.z() - 2.0) curve.attach(self) self.curves['Total'] = curve self.data['Total'] = np.zeros(HISTORY, np.float) curve = CpuCurve('Idle') curve.setColor(Qt.darkCyan) curve.setZ(curve.z() - 3.0) curve.attach(self) self.curves['Idle'] = curve self.data['Idle'] = np.zeros(HISTORY, np.float) self.showCurve(self.curves['System'], True) self.showCurve(self.curves['User'], True) self.showCurve(self.curves['Total'], False) self.showCurve(self.curves['Idle'], False) self.startTimer(1000) legend.SIG_CHECKED.connect(self.showCurve) self.replot()
def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.qwtPlot = QwtPlot(self.centralwidget) self.qwtPlot.setObjectName(_fromUtf8("qwtPlot")) self.verticalLayout.addWidget(self.qwtPlot) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.groupBox = QtGui.QGroupBox(self.centralwidget) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.groupBox) self.horizontalLayout_2.setContentsMargins(-1, 0, -1, 0) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.checkBox = QtGui.QCheckBox(self.groupBox) self.checkBox.setChecked(True) self.checkBox.setObjectName(_fromUtf8("checkBox")) self.horizontalLayout_2.addWidget(self.checkBox) self.checkBox_2 = QtGui.QCheckBox(self.groupBox) self.checkBox_2.setObjectName(_fromUtf8("checkBox_2")) self.horizontalLayout_2.addWidget(self.checkBox_2) self.checkBox_3 = QtGui.QCheckBox(self.groupBox) self.checkBox_3.setObjectName(_fromUtf8("checkBox_3")) self.horizontalLayout_2.addWidget(self.checkBox_3) self.checkBox_4 = QtGui.QCheckBox(self.groupBox) self.checkBox_4.setObjectName(_fromUtf8("checkBox_4")) self.horizontalLayout_2.addWidget(self.checkBox_4) self.checkBox_5 = QtGui.QCheckBox(self.groupBox) self.checkBox_5.setObjectName(_fromUtf8("checkBox_5")) self.horizontalLayout_2.addWidget(self.checkBox_5) self.horizontalLayout.addWidget(self.groupBox) self.label = QtGui.QLabel(self.centralwidget) self.label.setObjectName(_fromUtf8("label")) self.horizontalLayout.addWidget(self.label) self.samplesEdit = QtGui.QLineEdit(self.centralwidget) self.samplesEdit.setObjectName(_fromUtf8("samplesEdit")) self.horizontalLayout.addWidget(self.samplesEdit) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.label_2 = QtGui.QLabel(self.centralwidget) self.label_2.setObjectName(_fromUtf8("label_2")) self.horizontalLayout.addWidget(self.label_2) self.delayEdit = QtGui.QLineEdit(self.centralwidget) self.delayEdit.setObjectName(_fromUtf8("delayEdit")) self.horizontalLayout.addWidget(self.delayEdit) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.measureButton = QtGui.QPushButton(self.centralwidget) self.measureButton.setObjectName(_fromUtf8("measureButton")) self.horizontalLayout.addWidget(self.measureButton) self.closeButton = QtGui.QPushButton(self.centralwidget) self.closeButton.setObjectName(_fromUtf8("closeButton")) self.horizontalLayout.addWidget(self.closeButton) self.verticalLayout.addLayout(self.horizontalLayout) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 30)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
def __init__(self, *args): QwtPlot.__init__(self, *args) # set plot title self.setTitle('ImagePlot') # set plot layout self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # set legend legend = QwtLegend() legend.setDefaultItemMode(QwtLegendData.Clickable) self.insertLegend(legend, QwtPlot.RightLegend) # set axis titles self.setAxisTitle(QwtPlot.xBottom, 'time (s)') self.setAxisTitle(QwtPlot.yLeft, 'frequency (Hz)') colorMap = QwtLinearColorMap(Qt.blue, Qt.red) interval = QwtInterval(-1, 1) self.enableAxis(QwtPlot.yRight) self.setAxisScale(QwtPlot.yRight, -1, 1) self.axisWidget(QwtPlot.yRight).setColorBarEnabled(True) self.axisWidget(QwtPlot.yRight).setColorMap(interval, colorMap) # calculate 3 NumPy arrays x = np.arange(-2*np.pi, 2*np.pi, 0.01) y = np.pi*np.sin(x) z = 4*np.pi*np.cos(x)*np.cos(x)*np.sin(x) # attach a curve curve = QwtPlotCurve('y = pi*sin(x)') curve.attach(self) curve.setPen(QPen(Qt.green, 2)) curve.setData(x, y) # attach another curve curve = QwtPlotCurve('y = 4*pi*sin(x)*cos(x)**2') curve.attach(self) curve.setPen(QPen(Qt.black, 2)) curve.setData(x, z) # attach a grid grid = QwtPlotGrid() grid.attach(self) grid.setPen(QPen(Qt.black, 0, Qt.DotLine)) # attach a horizontal marker at y = 0 marker = QwtPlotMarker() marker.attach(self) marker.setValue(0.0, 0.0) marker.setLineStyle(QwtPlotMarker.HLine) marker.setLabelAlignment(Qt.AlignRight | Qt.AlignTop) marker.setLabel(QwtText('y = 0')) # attach a vertical marker at x = pi marker = QwtPlotMarker() marker.attach(self) marker.setValue(np.pi, 0.0) marker.setLineStyle(QwtPlotMarker.VLine) marker.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) marker.setLabel(QwtText('x = pi')) # attach a plot image plotImage = PlotImage('Image') plotImage.attach(self) plotImage.setData(square(512, -2*np.pi, 2*np.pi), (-2*np.pi, 2*np.pi), (-2*np.pi, 2*np.pi)) legend.SIG_CLICKED.connect(self.toggleVisibility) # replot self.replot()
def __init__(self, *args): QwtPlot.__init__(self, *args) self.uut_dev = None self.timerId = None #self.interval = 250 # ms self.interval = config.interval # ms fileTIME = datetime.datetime.now() File_timestamp = "%04d-%02d-%02d_%02d%02d%02d" % ( fileTIME.year, fileTIME.month, fileTIME.day, fileTIME.hour, fileTIME.minute, fileTIME.second) self.fileNamme = '.\data\data_%s.txt' % File_timestamp print('Raw data record file name:%s' % self.fileNamme) # default parameters from config file self.x_ZERO = config.X_lower self.x_range = config.X_upper self.x_interval = config.X_grid_interval self.y_range_Upper = config.Y_upper self.y_range_Lower = config.Y_lower self.y_interval = config.Y_grid_interval self.unit = 'kPa' # default value, will replaced by actual reading. #self.getReadingCommand = r"UPPER_VAL?\r\n" # default pass and pac #self.getResp_rex = r'^[-]?([0-9]{1,}[.]?[0-9]*)' self.lenth = config.Slope_lenth # 40 = 10s caculate the slowrate # QwtPlot property # Initialize 坐标轴 self.setCanvasBackground(Qt.white) #Qt.white self.alignScales() grid = QwtPlotGrid() grid.attach(self) grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine)) # x Axis property #self.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw(self.cpuStat.upTime())) #timeScale = QwtDateScaleDraw(Qt.LocalTime) #print(timeScale) #self.setAxisScaleDraw(QwtPlot.xBottom, timeScale) self.setAxisScale(QwtPlot.xBottom, 0.0, self.x_range, self.x_interval) #self.setAxisAutoScale(QwtPlot.yLeft,True) #self.setAxisScale(QwtPlot.yLeft,99.99,100.0,0.0005) self.setAxisScale(QwtPlot.yLeft, self.y_range_Lower, self.y_range_Upper, self.y_interval) self.setAxisLabelRotation(QwtPlot.xBottom, -45.0) self.x = np.arange( 0.0, self.x_range + 1, 0.25 ) #0.25 for ONE POINT, THIS SHOULD BE Align to the reading rate:250ms #self.z = np.zeros(len(self.x), np.float) list = [] for i in range(len(self.x)): list.append(0.0) self.z = np.array(list) rlist = [] for i in range(self.lenth): # 10s rlist.append(0.0) self.RateList = np.array(rlist) self.setTitle("UUT Reading Monitor - OutPort(%s)\r\n" % (self.unit)) #self.insertLegend(QwtLegend(), QwtPlot.RightLegend); self.curveL = QwtPlotCurve("UUT Reading") self.curveL.attach(self) pen = QPen(Qt.red) pen.setWidth(1.5) #pen.setWidth(1) self.curveL.setPen(pen) font = QFont() font.setFamily("Calibri") #,Consolas font.setPointSize(16) # show the latest reading. line and point value self.peakMarker = m = QwtPlotMarker() m.setLineStyle(QwtPlotMarker.HLine) m.setLabelAlignment(Qt.AlignLeft | Qt.AlignTop) m.setLinePen(QPen(Qt.blue, 1.5, Qt.DashDotLine)) text = QwtText('Reading: ----') text.setColor(Qt.red) text.setBackgroundBrush(QBrush(self.canvasBackground())) text.setFont(font) m.setLabel(text) # MarkPoint symbol m.setSymbol( QwtSymbol(QwtSymbol.Diamond, QBrush(Qt.blue), QPen(Qt.green), QSize(7, 7))) m.attach(self) # text marker , display slope rate self.txtMarker = m = QwtPlotMarker() m.setValue(self.x_range / 2, self.y_range_Upper - self.y_interval / 2) # show position m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) text = QwtText('Slope Rate: ----') text.setFont(font) text.setColor(Qt.white) text.setBackgroundBrush(QBrush(Qt.black)) text.setBorderPen(QPen(Qt.red, 2)) m.setLabel(text) m.attach(self) self.setAxisTitle(QwtPlot.xBottom, "Time (seconds)") self.setAxisTitle(QwtPlot.yLeft, "UUT - Reading(%s)" % (self.unit)) self.replot() #self.startTimer(250)#ms# FOR GET READING #self.starttime = time.clock();#unit: s python2 self.starttime = time.time() # python3 self.idx = 0 self.readfmt = "%f" self.Saveinfo("Starting...")
def __init__(self, *args): QWidget.__init__(self, *args) layout = QGridLayout(self) # try to create a plot for SciPy arrays # make a curve and copy the data numpy_curve = QwtPlotCurve('y = lorentzian(x)') x = np.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 = QwtPlot(self) numpy_plot.setTitle('numpy array') numpy_plot.setCanvasBackground(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(QPen(Qt.red)) layout.addWidget(numpy_plot, 0, 0) numpy_plot.replot() # create a plot widget for lists of Python floats list_plot = QwtPlot(self) list_plot.setTitle('Python list') list_plot.setCanvasBackground(Qt.white) list_plot.plotLayout().setCanvasMargin(0) list_plot.plotLayout().setAlignCanvasToScales(True) x = drange(0.0, 10.0, 0.01) y = [lorentzian(item) for item in x] # insert a curve, make it red and copy the lists list_curve = QwtPlotCurve('y = lorentzian(x)') list_curve.attach(list_plot) list_curve.setPen(QPen(Qt.red)) list_curve.setData(x, y) layout.addWidget(list_plot, 0, 1) list_plot.replot()
class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.resize(800, 600) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.qwtPlot = QwtPlot(self.centralwidget) self.qwtPlot.setObjectName(_fromUtf8("qwtPlot")) self.verticalLayout.addWidget(self.qwtPlot) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.groupBox = QtGui.QGroupBox(self.centralwidget) self.groupBox.setObjectName(_fromUtf8("groupBox")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.groupBox) self.horizontalLayout_2.setContentsMargins(-1, 0, -1, 0) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.radioButton = QtGui.QRadioButton(self.groupBox) self.radioButton.setChecked(True) self.radioButton.setObjectName(_fromUtf8("radioButton")) self.horizontalLayout_2.addWidget(self.radioButton) self.radioButton_2 = QtGui.QRadioButton(self.groupBox) self.radioButton_2.setObjectName(_fromUtf8("radioButton_2")) self.horizontalLayout_2.addWidget(self.radioButton_2) self.radioButton_3 = QtGui.QRadioButton(self.groupBox) self.radioButton_3.setObjectName(_fromUtf8("radioButton_3")) self.horizontalLayout_2.addWidget(self.radioButton_3) self.radioButton_4 = QtGui.QRadioButton(self.groupBox) self.radioButton_4.setObjectName(_fromUtf8("radioButton_4")) self.horizontalLayout_2.addWidget(self.radioButton_4) self.radioButton_5 = QtGui.QRadioButton(self.groupBox) self.radioButton_5.setObjectName(_fromUtf8("radioButton_5")) self.horizontalLayout_2.addWidget(self.radioButton_5) self.horizontalLayout.addWidget(self.groupBox) self.label = QtGui.QLabel(self.centralwidget) self.label.setObjectName(_fromUtf8("label")) self.horizontalLayout.addWidget(self.label) self.samplesEdit = QtGui.QLineEdit(self.centralwidget) self.samplesEdit.setObjectName(_fromUtf8("samplesEdit")) self.horizontalLayout.addWidget(self.samplesEdit) spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.label_2 = QtGui.QLabel(self.centralwidget) self.label_2.setObjectName(_fromUtf8("label_2")) self.horizontalLayout.addWidget(self.label_2) self.delayEdit = QtGui.QLineEdit(self.centralwidget) self.delayEdit.setObjectName(_fromUtf8("delayEdit")) self.horizontalLayout.addWidget(self.delayEdit) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.measureButton = QtGui.QPushButton(self.centralwidget) self.measureButton.setObjectName(_fromUtf8("measureButton")) self.horizontalLayout.addWidget(self.measureButton) self.closeButton = QtGui.QPushButton(self.centralwidget) self.closeButton.setObjectName(_fromUtf8("closeButton")) self.horizontalLayout.addWidget(self.closeButton) self.verticalLayout.addLayout(self.horizontalLayout) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 30)) self.menubar.setObjectName(_fromUtf8("menubar")) MainWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) MainWindow.setStatusBar(self.statusbar) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) self.groupBox.setTitle(_translate("MainWindow", "Input Channel", None)) self.radioButton.setText(_translate("MainWindow", "A1 ", None)) self.radioButton_2.setText(_translate("MainWindow", "A2 ", None)) self.radioButton_3.setText(_translate("MainWindow", "IN1", None)) self.radioButton_4.setText(_translate("MainWindow", "IN2", None)) self.radioButton_5.setText(_translate("MainWindow", "SEN", None)) self.label.setText(_translate("MainWindow", "Samples:", None)) self.samplesEdit.setText(_translate("MainWindow", "1000", None)) self.label_2.setText(_translate("MainWindow", "Time gap µs:", None)) self.delayEdit.setText(_translate("MainWindow", "200", None)) self.measureButton.setText(_translate("MainWindow", "Measure", None)) self.closeButton.setText(_translate("MainWindow", "Close", None))
class MapDemo(QMainWindow): def __init__(self, *args): QMainWindow.__init__(self, *args) self.plot = QwtPlot(self) self.plot.setTitle("A Simple Map Demonstration") self.plot.setCanvasBackground(Qt.white) self.plot.setAxisTitle(QwtPlot.xBottom, "x") self.plot.setAxisTitle(QwtPlot.yLeft, "y") self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0) self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0) self.setCentralWidget(self.plot) # Initialize map data self.count = self.i = 1000 self.xs = np.zeros(self.count, np.float) self.ys = np.zeros(self.count, np.float) self.kappa = 0.2 self.curve = QwtPlotCurve("Map") self.curve.attach(self.plot) self.curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.blue), QSize(5, 5))) self.curve.setPen(QPen(Qt.cyan)) toolBar = QToolBar(self) self.addToolBar(toolBar) # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz) self.ticks = 10 self.tid = self.startTimer(self.ticks) self.timer_tic = None self.user_tic = None self.system_tic = None self.plot.replot() def setTicks(self, ticks): self.i = self.count self.ticks = int(ticks) self.killTimer(self.tid) self.tid = self.startTimer(ticks) def resizeEvent(self, event): self.plot.resize(event.size()) self.plot.move(0, 0) def moreData(self): if self.i == self.count: self.i = 0 self.x = random.random() self.y = random.random() self.xs[self.i] = self.x self.ys[self.i] = self.y self.i += 1 chunks = [] self.timer_toc = time.time() if self.timer_tic: chunks.append("wall: %s s." % (self.timer_toc-self.timer_tic)) print(' '.join(chunks)) self.timer_tic = self.timer_toc else: self.x, self.y = standard_map(self.x, self.y, self.kappa) self.xs[self.i] = self.x self.ys[self.i] = self.y self.i += 1 def timerEvent(self, e): self.moreData() self.curve.setData(self.xs[:self.i], self.ys[:self.i]) self.plot.replot()
# -*- coding: utf-8 -*- __author__ = 'Valeriy' from qwt.qt.QtGui import QApplication from qwt import QwtPlot, QwtPlotCurve import numpy as np app = QApplication([]) # x = [1,2,3,4,5,6,7,8,9] # y1 = [3.2, 5.1 ,7.0, 4.24, 4.41, 8.34, 2.21, 5.657, 6.1] x = [] y1 = [] my_plot = QwtPlot("Two curves") curve1 = QwtPlotCurve("Curve 1") my_plot.resize(600, 300) curve1.setData(x, y1) curve1.attach(my_plot) # my_plot.replot() my_plot.show() app.exec_() # SELECT PrepData FROM= Pdata WHERE ((PNameId=2) AND (SNameId = 14) AND (YearId=2012))