def addcurve(self, key, index, title, scale, offset): series = TimeSeries(key, self.props['plotinterval'], scale, offset, self.props['plotwindow'], self) series.init_empty() curve = PlotCurve([currenttime()], [0], legend=title) self.plotcurves[series] = curve self.ncurves += 1 self.curves.append(curve) self.axes.addCurves(curve) self.series[key, index] = series self.widget.update() # record the current value at least every 5 seconds, to avoid curves # not updating if the value doesn't change def update(): series.synthesize_value() self.ctimers[curve] = QTimer(singleShot=True) self.ctimers[curve].timeout.connect(update)
def __init__(self, *args, **kwargs): QtGui.QMainWindow.__init__(self, *args, **kwargs) self._grw = InteractiveGRWidget() self.setCentralWidget(self._grw) viewport = [0.1, 0.88, 0.1, 0.88] x = arange(0, 2 * pi, 0.01) y = sin(x) self.curve = PlotCurve(x, y) axes = ScaledPlotAxes(viewport) axes.addCurves(self.curve) plot = Plot(viewport).addAxes(axes) plot.title = "QtGR Timer example" plot.subTitle = "Plotting Live-Data" plot.xlabel = "t" plot.ylabel = "sin(t)" plot.autoscale = PlotAxes.SCALE_X | PlotAxes.SCALE_Y self._grw.addPlot(plot) timer = QtCore.QTimer(self) timer.timeout.connect(self.updateData) timer.start(40)
def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)), "qtgrdemo.ui"), self) dictPrintType = dict(gr.PRINT_TYPE) map(dictPrintType.pop, [gr.PRINT_JPEG, gr.PRINT_TIF]) self._saveTypes = (";;".join(dictPrintType.values()) + ";;" + ";;".join(gr.GRAPHIC_TYPE.values())) self._saveName = None self._title = unicode(self.windowTitle()) self._startupTime = time.time() self._chkLogX.stateChanged.connect(self._logXClicked) self._chkLogY.stateChanged.connect(self._logYClicked) self._chkGrid.stateChanged.connect(self._gridClicked) self._chkErr.stateChanged.connect(self._errorsClicked) self._chkKeepRatio.stateChanged.connect(self._keepRatioClicked) self._btnReset.clicked.connect(self._resetClicked) self._btnPick.clicked.connect(self._pickClicked) self._shell.returnPressed.connect(self._shellEx) self._actionSave.triggered.connect(self.save) self._actionPrint.triggered.connect(self.printGR) self._gr.logXinDomain.connect(self._logXinDomain) self._gr.logYinDomain.connect(self._logYinDomain) self._gr.modePick.connect(self._pickModeChanged) guiConn = GUIConnector(self._gr) guiConn.connect(MouseEvent.MOUSE_MOVE, self.mouseMoveGr) guiConn.connect(PickEvent.PICK_PRESS, self.pointPickGr) guiConn.connect(LegendEvent.ROI_CLICKED, self.legendClick) guiConn.connect(LegendEvent.ROI_OVER, self.legendOver) x = [-3.3 + t * .1 for t in range(66)] y = [t ** 5 - 13 * t ** 3 + 36 * t for t in x] x2 = [-3.5 + i * .5 for i in range(0, 15)] y2 = x2 dneg = map(lambda y: y - 0.25 * abs(y), y) dpos = map(lambda y: y + 0.25 * abs(y), y) self._errBar = ErrorBar(x, y, dneg, dpos) self._curveFoo = PlotCurve(x, y, legend="foo bar") axes = PlotAxes().addCurves(self._curveFoo) axes.setXtickCallback(self._xtickCallBack) self._plot = Plot((.1, .92, .2, .88)).addAxes(axes, PlotAxes(drawX=False).plot(x2, y2)) self._plot.offsetXLabel = -.1 self._plot2 = Plot((.1, .95, .15, .88)).addAxes(PlotAxes().addCurves(PlotCurve(x2, y2, legend="second"))) self._plot.title = "QtGR Demo" self._plot.subTitle = "Multiple Axes Example" self._plot.xlabel = "x" self._plot.ylabel = "f(x)" self._plot.setLegend(True) self._gr.addPlot(self._plot) self._plot2.title = "Second Widget" self._plot2.subTitle = "Linear Example (less interactive)" self._plot2.xlabel = "x2" self._plot2.ylabel = "f2(x2)" self._plot2.setLegend(True) self._plot2.setGrid(False) self._gr2.addPlot(self._plot2)
def __init__(self, *args, **kwargs): PlotCurve.__init__(self, *args, **kwargs) self._dependent = []
def drawGR(self): PlotCurve.drawGR(self) for dep in self.dependent: if dep.visible: dep.drawGR()
import gr from gr.pygr import Plot, PlotAxes, PlotCurve, Text tx, ty = 0, -20 x = [-3.3 + t * .1 for t in range(66)] y = [t**5 - 13 * t**3 + 36 * t for t in x] txtfmt = "Text drawn on\n(%g, %g) with\nhalign left, valign top" plt = Plot((.1, .95, .1, .88)) plt.title = "Text on Axes Example" plt.subTitle = "Show usage of gr.pygr.Text" plt.xlabel = "x" plt.ylabel = "y" curve = PlotCurve(x, y, legend="foo bar") axes = PlotAxes(plt.viewport).addCurves(curve) axes.setWindow(-4.0, 4.0, -60.0, 40.0) text = Text(tx, -ty, txtfmt % (tx, -ty), axes, .02) plt.addAxes(axes) text2 = Text(tx, ty, txtfmt % (tx, ty), axes, .02) tbx, tby = text2.getBoundingBox() plt.drawGR() text.drawGR() text2.drawGR() # set viewport and window accordingly to draw in NDC space gr.setviewport(0, axes.sizex, 0, axes.sizey) gr.setwindow(0, axes.sizex, 0, axes.sizey) gr.fillarea(tbx, tby)
def __init__(self, *args, **kwargs): # fill values for masked x, y self.fillx = kwargs.pop('fillx', 0) self.filly = kwargs.pop('filly', 0) PlotCurve.__init__(self, *args, **kwargs)
def drawGR(self): gr.setmarkersize(self._markersize) PlotCurve.drawGR(self)