def plotDataVersusData(self, xData, xBounds, yData, yBounds, name, connectPoints, windowSize=None): if not windowSize: windowSize = self.windowSize if len(xData) == 0: print 'X Data stream', name, 'empty: skipping plot' return if len(yData) == 0: print 'Y Data stream', name, 'empty: skipping plot' return (xLower, xUpper) = self.getBounds(xData, xBounds) (yLower, yUpper) = self.getBounds(yData, yBounds) # if len(self.plotWindows) > self.plotWindowIdx: # w = self.plotWindows[self.plotWindowIdx] # w.reopenWindow(windowSize, windowSize, # xLower, xUpper, yLower, yUpper, name) # self.plotWindowIdx += 1 # else: w = gw.GraphingWindow(windowSize, windowSize, xLower, xUpper, yLower, yUpper, name) self.plotWindows.append(w) if connectPoints: w.graphContinuousSet(xData, yData) else: w.graphPointSet(xData, yData)
def plot(self, start=0, end=100, newWindow='Signal value versus time', color='blue', parent=None, ps=None, xminlabel=0, xmaxlabel=0, yOrigin=None): # bkph """ Make a plot of this signal. :param start: first value to plot; defaults to 0 :param end: last value to plot; defaults to 100; must be > start :param newWindow: makes a new window with this value as title, unless the value is False, in which case it plots the signal in the currently active plotting window :param color: string specifying color of plot; all simple color names work :param parent: An instance of ``tk.tk``. You probably should just leave this at the default unless you're making plots from another application. :param ps: If not ``None``, then it should be a pathname; we'll write a postscript version of this graph to that path. """ samples = [self.sample(i) for i in range(start, end)] if len(samples) == 0: raise Exception, 'Plot range is empty' if yOrigin == None: minY = min(samples) else: minY = yOrigin maxY = max(samples) if maxY == minY: margin = 1.0 else: # margin = (maxY - minY) * 0.05 margin = 0 # override bkph if newWindow == True or newWindow == False: title = 'Signal value vs time' else: title = newWindow if parent: # Make a window under a different tk parent w = gw.GraphingWindow(\ graphwidth, graphheight, start, end, minY-margin, maxY+margin, title, parent, xminlabel = xminlabel, xmaxlabel = xmaxlabel) # bkph else: # Use this class's tk instance if newWindow or Signal.__w == None: Signal.__w = gw.GraphingWindow(\ graphwidth, graphheight, start, end, minY-margin, maxY+margin, title, xminlabel = xminlabel, xmaxlabel = xmaxlabel) # bkph w = Signal.__w def sam(n): if n >= start: return samples[n - start] else: raise Exception w.graphDiscrete(sam, color) if ps: w.postscript(ps)