Python pyqtgraph.PlotCurveItem() Examples
The following are 30
code examples of pyqtgraph.PlotCurveItem().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyqtgraph
, or try the search function
.
Example #1
Source File: multiplePlotSpeedTest.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 6 votes |
def plot(): start = pg.ptime.time() n = 15 pts = 100 x = np.linspace(0, 0.8, pts) y = np.random.random(size=pts)*0.8 for i in range(n): for j in range(n): ## calling PlotWidget.plot() generates a PlotDataItem, which ## has a bit more overhead than PlotCurveItem, which is all ## we need here. This overhead adds up quickly and makes a big ## difference in speed. #plt.plot(x=x+i, y=y+j) plt.addItem(pg.PlotCurveItem(x=x+i, y=y+j)) #path = pg.arrayToQPath(x+i, y+j) #item = QtGui.QGraphicsPathItem(path) #item.setPen(pg.mkPen('w')) #plt.addItem(item) dt = pg.ptime.time() - start print("Create plots took: %0.3fms" % (dt*1000)) ## Plot and clear 5 times, printing the time it took
Example #2
Source File: camera_display.py From stytra with GNU General Public License v3.0 | 6 votes |
def __init__(self, **kwargs): """ """ super().__init__(**kwargs) # Draw ROI for tail selection: self.tail_params = self.experiment.pipeline.tailtrack._params self.roi_tail = SingleLineROI( self.tail_points(), pen=dict(color=(40, 5, 200), width=3) ) # Prepare curve for plotting tracked tail position: self.curve_tail = pg.PlotCurveItem(pen=dict(color=(230, 40, 5), width=3)) self.display_area.addItem(self.curve_tail) self.initialise_roi(self.roi_tail) self.setting_param_val = False
Example #3
Source File: AttributeCharts.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 6 votes |
def drawHistogram(self, values, xmin, xmax, bins): # compute the histogram if bins >= 50: bin = 51 else: bin = bins+1 y, x = np.histogram(values, bins=np.linspace(xmin, xmax, num=bin)) # plot the chart if has_pyqtgraph: curve = pg.PlotCurveItem() self.plot.clear() curve.setData(x, y, stepMode=True, fillLevel=0, brush=(230, 230, 230), pen=pg.mkPen(None)) self.plot.addItem(curve) # add the selection tool self.region = pg.LinearRegionItem([xmax,xmax],bounds=[xmin, xmax]) self.region.sigRegionChangeFinished.connect(self.changedHistogramSelection) if self.show_lines: self.plot.addItem(self.region) # add the selection plot self.clearHistogramSelection() self.hist_selection = pg.PlotCurveItem() self.plot.addItem(self.hist_selection) # allow selection of items in chart and selecting them on the map
Example #4
Source File: AttributeCharts.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 6 votes |
def __init__(self, iface, plot): QObject.__init__(self) self.iface = iface self.plot = plot self.add_selection = False self.just_selected = False self.show_lines = True if has_pyqtgraph: self.plot.setClipToView(True) self.plot.enableAutoRange(enable=True) self.hist_selection = pg.PlotCurveItem() self.scatter_selection = [] self.scatter = pg.ScatterPlotItem() self.scatter_points = {} self.region = pg.LinearRegionItem() #self.selected_points = [] self.selected_points = pg.ScatterPlotItem() self.regress_line = pg.InfiniteLine() #self.roi = None #---- # Histogram functions
Example #5
Source File: guiContainer.py From wavePicker with GNU General Public License v2.0 | 6 votes |
def initTracePlot(self): ''' Inits the station.plotItem title and the self.PlotCurveItem also connects the graph to self.pickPhase() ''' self.station.plotItem.setTitle(self.tr.id) self.station.plotItem.titleLabel.setAttr('justify', 'left') self.station.plotItem.titleLabel.setMaximumHeight(0) self.station.plotItem.layout.setRowFixedHeight(0, 0) self.traceItem = pg.PlotCurveItem() self.traceItem.setClickable(True, width=50) self.traceItem.sigClicked.connect(self.pickPhase) self.station.plotItem.addItem(self.traceItem) self.plotTraceItem() self.plotPickItems()
Example #6
Source File: test_PlotCurveItem.py From soapy with GNU General Public License v3.0 | 6 votes |
def test_PlotCurveItem(): p = pg.GraphicsWindow() p.ci.layout.setContentsMargins(4, 4, 4, 4) # default margins vary by platform v = p.addViewBox() p.resize(200, 150) data = np.array([1,4,2,3,np.inf,5,7,6,-np.inf,8,10,9,np.nan,-1,-2,0]) c = pg.PlotCurveItem(data) v.addItem(c) v.autoRange() # Check auto-range works. Some platform differences may be expected.. checkRange = np.array([[-1.1457564053237301, 16.145756405323731], [-3.076811473165955, 11.076811473165955]]) assert np.allclose(v.viewRange(), checkRange) assertImageApproved(p, 'plotcurveitem/connectall', "Plot curve with all points connected.") c.setData(data, connect='pairs') assertImageApproved(p, 'plotcurveitem/connectpairs', "Plot curve with pairs connected.") c.setData(data, connect='finite') assertImageApproved(p, 'plotcurveitem/connectfinite', "Plot curve with finite points connected.") c.setData(data, connect=np.array([1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0])) assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
Example #7
Source File: test_PlotCurveItem.py From tf-pose with Apache License 2.0 | 6 votes |
def test_PlotCurveItem(): p = pg.GraphicsWindow() p.ci.layout.setContentsMargins(4, 4, 4, 4) # default margins vary by platform v = p.addViewBox() p.resize(200, 150) data = np.array([1,4,2,3,np.inf,5,7,6,-np.inf,8,10,9,np.nan,-1,-2,0]) c = pg.PlotCurveItem(data) v.addItem(c) v.autoRange() # Check auto-range works. Some platform differences may be expected.. checkRange = np.array([[-1.1457564053237301, 16.145756405323731], [-3.076811473165955, 11.076811473165955]]) assert np.allclose(v.viewRange(), checkRange) assertImageApproved(p, 'plotcurveitem/connectall', "Plot curve with all points connected.") c.setData(data, connect='pairs') assertImageApproved(p, 'plotcurveitem/connectpairs', "Plot curve with pairs connected.") c.setData(data, connect='finite') assertImageApproved(p, 'plotcurveitem/connectfinite', "Plot curve with finite points connected.") c.setData(data, connect=np.array([1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0])) assertImageApproved(p, 'plotcurveitem/connectarray', "Plot curve with connection array.")
Example #8
Source File: onlinewaveformhistviewer.py From tridesclous with MIT License | 6 votes |
def initialize_plot(self): self.viewBox = MyViewBox() self.viewBox.doubleclicked.connect(self.open_settings) self.viewBox.gain_zoom.connect(self.gain_zoom) self.viewBox.disableAutoRange() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() self.image = pg.ImageItem() self.plot.addItem(self.image) self.curve_spike = pg.PlotCurveItem() self.plot.addItem(self.curve_spike) self.curve_limit = pg.PlotCurveItem() self.plot.addItem(self.curve_limit) self.change_lut()
Example #9
Source File: SpectrographWidget.py From OpenNFB with GNU General Public License v3.0 | 6 votes |
def __init__(self): super(SpectrographWidget, self).__init__() self.setLabel('bottom', 'Index', units='B') nPlots = 18 nSamples = 500 self.curves = [] for i in range(nPlots): c = pg.PlotCurveItem(pen=(i, nPlots * 1.3)) self.addItem(c) c.setPos(0, i * 6) self.curves.append(c) c.setData(np.zeros(nSamples)) self.setYRange(0, nPlots * 6) self.setXRange(0, nSamples) self.buffer = np.zeros(nSamples) self.nPlots = nPlots self.filter = IIRFilter()
Example #10
Source File: isiviewer.py From tridesclous with MIT License | 6 votes |
def refresh(self): self.plot.clear() n = 0 for k in self.controller.positive_cluster_labels: if not self.controller.cluster_visible[k]: continue if k not in self.all_isi: self._compute_isi(k) isi = self.all_isi[k] if len(isi) ==0: return bins = np.arange(self.params['bin_min'], self.params['bin_max'], self.params['bin_size']) count, bins = np.histogram(isi, bins=bins) qcolor = self.controller.qcolors[k] curve = pg.PlotCurveItem(bins[:-1], count, pen=pg.mkPen(qcolor, width=3)) self.plot.addItem(curve)
Example #11
Source File: guiContainer.py From wavePicker with GNU General Public License v2.0 | 5 votes |
def plotTraceItem(self): ''' Plots the pg.PlotCurveItem into self.station.plotItem ''' self.plotTrace = self.tr.copy() # Filter if necessary if self.station.parent.parent.filterArgs is not None: self.plotTrace.filter('bandpass', **self.station.parent.parent.filterArgs) self.traceItem.setData(y=self.plotTrace.data, antialias=True) self.station.plotItem.getAxis('bottom').setScale(self.tr.stats.delta)
Example #12
Source File: hdf5.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwds): self.hdf5 = None self.limit = 10000 # maximum number of samples to be plotted pg.PlotCurveItem.__init__(self, *args, **kwds)
Example #13
Source File: OWAnnotateProjection.py From orange3-bioinformatics with GNU General Public License v3.0 | 5 votes |
def _update_cluster_hull(self): for item in self.cluster_hulls_items: self.plot_widget.removeItem(item) if not self.show_cluster_hull: return hulls = self.master.get_cluster_hulls() if hulls is None: return for hull, color in hulls: pen = pg.mkPen(color=QColor(*color), style=Qt.DashLine, width=3) item = pg.PlotCurveItem(x=hull[:, 0], y=hull[:, 1], pen=pen, antialias=True) self.plot_widget.addItem(item) self.cluster_hulls_items.append(item)
Example #14
Source File: OWDifferentialExpression.py From orange3-bioinformatics with GNU General Public License v3.0 | 5 votes |
def __init__(self, parent=None, **kwargs): pg.PlotWidget.__init__(self, parent, **kwargs) self.getAxis("bottom").setLabel("Score") self.getAxis("left").setLabel("Counts") self.__data = None self.__histcurve = None self.__mode = Histogram.NoSelection self.__min = 0 self.__max = 0 def makeline(pos): pen = QPen(Qt.darkGray, 1) pen.setCosmetic(True) line = InfiniteLine(angle=90, pos=pos, pen=pen, movable=True) line.setCursor(Qt.SizeHorCursor) return line self.__cuthigh = makeline(self.__max) self.__cuthigh.sigPositionChanged.connect(self.__on_cuthigh_changed) self.__cuthigh.sigPositionChangeFinished.connect(self.selectionEdited) self.__cutlow = makeline(self.__min) self.__cutlow.sigPositionChanged.connect(self.__on_cutlow_changed) self.__cutlow.sigPositionChangeFinished.connect(self.selectionEdited) brush = pg.mkBrush((200, 200, 200, 180)) self.__taillow = pg.PlotCurveItem(fillLevel=0, brush=brush, pen=QPen(Qt.NoPen)) self.__taillow.setVisible(False) self.__tailhigh = pg.PlotCurveItem(fillLevel=0, brush=brush, pen=QPen(Qt.NoPen)) self.__tailhigh.setVisible(False)
Example #15
Source File: OWDifferentialExpression.py From orange3-bioinformatics with GNU General Public License v3.0 | 5 votes |
def setData(self, hist, bins=None): """ Set the histogram data """ if bins is None: bins = np.arange(len(hist)) self.__data = (hist, bins) if self.__histcurve is None: self.__histcurve = pg.PlotCurveItem(x=bins, y=hist, stepMode=True) else: self.__histcurve.setData(x=bins, y=hist, stepMode=True) self.__update()
Example #16
Source File: ReceiveAndPlot.py From liblsl-Python with MIT License | 5 votes |
def __init__(self, info: pylsl.StreamInfo, plt: pg.PlotItem): super().__init__(info) # calculate the size for our buffer, i.e. two times the displayed data bufsize = (2 * math.ceil(info.nominal_srate() * plot_duration), info.channel_count()) self.buffer = np.empty(bufsize, dtype=self.dtypes[info.channel_format()]) empty = np.array([]) # create one curve object for each channel/line that will handle displaying the data self.curves = [pg.PlotCurveItem(x=empty, y=empty, autoDownsample=True) for _ in range(self.channel_count)] for curve in self.curves: plt.addItem(curve)
Example #17
Source File: AttributeCharts.py From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 | 5 votes |
def setHistogramSelection(self, values, xmin, xmax, bins): if has_pyqtgraph: self.clearHistogramSelection() if len(values) > 0: # compute the histogram if bins >= 50: bin = 51 else: bin = bins+1 y, x = np.histogram(values, bins=np.linspace(xmin, xmax, num=bin)) # plot the selection chart self.hist_selection = pg.PlotCurveItem() self.hist_selection.setData(x, y, stepMode=True, fillLevel=0, brush=(230, 0, 0), pen=pg.mkPen(None)) self.plot.addItem(self.hist_selection) if self.just_selected: # if the selection comes from the chart leave the selection region in place self.just_selected = False else: # if the selection comes from the map the values are not continuous: reset selection region self.region.blockSignals(True) self.region.setRegion((xmax, xmax)) self.region.blockSignals(False) else: # reset selection region self.region.blockSignals(True) self.region.setRegion((xmax, xmax)) self.region.blockSignals(False)
Example #18
Source File: uiKLine.py From uiKLine with MIT License | 5 votes |
def initplotKline(self): """初始化K线子图以及指标子图""" self.pwKL = self.makePI('_'.join([self.windowId,'PlotKL'])) self.candle = CandlestickItem(self.listBar) self.pwKL.addItem(self.candle) self.KLINEOI_CLOSE = pg.PlotCurveItem(pen=({'color': "w", 'width': 1})) self.pwKL.addItem(self.KLINEOI_CLOSE) self.KLINEOI_CLOSE.hide() self.MA_SHORTOI = pg.PlotCurveItem(pen=({'color': "r", 'width': 1})) self.pwKL.addItem(self.MA_SHORTOI) self.MA_SHORTOI.hide() self.MA_LONGOI = pg.PlotCurveItem(pen=({'color': "r", 'width': 1,'dash':[3, 3, 3, 3]})) self.pwKL.addItem(self.MA_LONGOI) self.MA_LONGOI.hide() self.start_date_Line = pg.InfiniteLine(angle=90, movable=False,pen=({'color': [255, 255, 255, 100], 'width': 0.5})) self.pwKL.addItem(self.start_date_Line) self.end_date_Line = pg.InfiniteLine(angle=90,movable=False,pen=({'color': [255, 255, 0, 100], 'width': 0.5})) self.pwKL.addItem(self.end_date_Line) self.pwKL.setMinimumHeight(350) self.pwKL.setXLink('_'.join([self.windowId,'PlotOI'])) self.pwKL.hideAxis('bottom') self.lay_KL.nextRow() self.lay_KL.addItem(self.pwKL) #----------------------------------------------------------------------
Example #19
Source File: camera_display.py From stytra with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.points_fish = pg.ScatterPlotItem( size=5, pxMode=True, brush=(255, 0, 0), pen=None ) self.lines_fish = pg.PlotCurveItem( connect="pairs", pen=pg.mkPen((10, 100, 200), width=3) ) self.display_area.addItem(self.points_fish) self.display_area.addItem(self.lines_fish) self.tracking_params = self.experiment.pipeline.fishtrack._params
Example #20
Source File: traceviewer.py From tridesclous with MIT License | 5 votes |
def _initialize_plot(self): self.curve_predictions = pg.PlotCurveItem(pen='#FF00FF', connect='finite') self.plot.addItem(self.curve_predictions) self.curve_residuals = pg.PlotCurveItem(pen='#FFFF00', connect='finite') self.plot.addItem(self.curve_residuals)
Example #21
Source File: hdf5.py From tf-pose with Apache License 2.0 | 5 votes |
def __init__(self, *args, **kwds): self.hdf5 = None self.limit = 10000 # maximum number of samples to be plotted pg.PlotCurveItem.__init__(self, *args, **kwds)
Example #22
Source File: multiplePlotSpeedTest.py From tf-pose with Apache License 2.0 | 5 votes |
def plot(): start = pg.ptime.time() n = 15 pts = 100 x = np.linspace(0, 0.8, pts) y = np.random.random(size=pts)*0.8 for i in range(n): for j in range(n): ## calling PlotWidget.plot() generates a PlotDataItem, which ## has a bit more overhead than PlotCurveItem, which is all ## we need here. This overhead adds up quickly and makes a big ## difference in speed. #plt.plot(x=x+i, y=y+j) plt.addItem(pg.PlotCurveItem(x=x+i, y=y+j)) #path = pg.arrayToQPath(x+i, y+j) #item = QtGui.QGraphicsPathItem(path) #item.setPen(pg.mkPen('w')) #plt.addItem(item) dt = pg.ptime.time() - start print("Create plots took: %0.3fms" % (dt*1000)) ## Plot and clear 5 times, printing the time it took
Example #23
Source File: uiKLine.py From uiKLine with MIT License | 5 votes |
def plotIndex_FIRST (self): """画指标""" # 检查是否有数据 if len(self.KLINE_SHORT_TERM_LIST_FIRST)==0 : self.refresh() return for arrow in self.KLINE_SHORT_TERM_LIST_FIRST_arrows: self.pwKL.removeItem(arrow) for curves in self.KLINE_SHORT_TERM_LIST_FIRST_curves: self.pwKL.removeItem(curves) for i in range(len(self.KLINE_SHORT_TERM_LIST_FIRST)): if self.KLINE_SHORT_TERM_LIST_FIRST[i] == 1: arrow = pg.ArrowItem(pos=(i, self.datas[i]['low']), size=7,tipAngle=55,tailLen=3,tailWidth=4, angle=90, brush=(225, 255, 0),pen=({'color': "FFFF00", 'width': 1})) self.pwKL.addItem(arrow) self.KLINE_SHORT_TERM_LIST_FIRST_arrows.append(arrow) if self.KLINE_SHORT_TERM_LIST_FIRST[i] == 2: arrow = pg.ArrowItem(pos=(i, self.datas[i]['high']),size=7,tipAngle=55,tailLen=3,tailWidth=4 ,angle=-90, brush=(225, 255, 0),pen=({'color': "FFFF00", 'width': 1})) self.pwKL.addItem(arrow) self.KLINE_SHORT_TERM_LIST_FIRST_arrows.append(arrow) last_x=-1 #上一个x last_y=-1 #上一个y last_v=-1 for i in range(len(self.KLINE_SHORT_TERM_LIST_FIRST)): if self.KLINE_SHORT_TERM_LIST_FIRST[i] != 0 : if last_x!=-1 and last_y!=-1 and last_v!=self.KLINE_SHORT_TERM_LIST_FIRST[i] and\ ((last_v == 1 and self.KLINE_SHORT_TERM_LIST_FIRST[i] == 2) and self.KLINE_LOW[last_x]<self.KLINE_HIGH[i]) or\ ((last_v == 2 and self.KLINE_SHORT_TERM_LIST_FIRST[i] == 1) and self.KLINE_HIGH[last_x]>self.KLINE_LOW[i]): curve = pg.PlotCurveItem(x=np.array([last_x,i]),y=np.array([last_y,self.datas[i]['low'] if self.KLINE_SHORT_TERM_LIST_FIRST[i]==1 else self.datas[i]['high']]),name='duo',pen=({'color': "FFFF00", 'width': 1})) self.pwKL.addItem(curve) self.KLINE_SHORT_TERM_LIST_FIRST_curves.append(curve) last_x =i if self.KLINE_SHORT_TERM_LIST_FIRST[i] ==1 : last_y=self.datas[i]['low'] elif self.KLINE_SHORT_TERM_LIST_FIRST[i] ==2 : last_y=self.datas[i]['high'] last_v=self.KLINE_SHORT_TERM_LIST_FIRST[i] #----------------------------------------------------------------------
Example #24
Source File: uiKLine.py From uiKLine with MIT License | 5 votes |
def plotIndex_ALL (self): """画指标""" # 检查是否有数据 if len(self.KLINE_SHORT_TERM_LIST_ALL)==0 : self.refresh() return for arrow in self.KLINE_SHORT_TERM_LIST_ALL_arrows: self.pwKL.removeItem(arrow) for curves in self.KLINE_SHORT_TERM_LIST_ALL_curves: self.pwKL.removeItem(curves) for i in range(len(self.KLINE_SHORT_TERM_LIST_ALL)): if self.KLINE_SHORT_TERM_LIST_ALL[i] == 1: arrow = pg.ArrowItem(pos=(i, self.datas[i]['low']), size=7,tipAngle=55,tailLen=3,tailWidth=4, angle=90, brush=(225, 0, 225),pen=({'color': "FF00FF", 'width': 1})) self.pwKL.addItem(arrow) self.KLINE_SHORT_TERM_LIST_ALL_arrows.append(arrow) if self.KLINE_SHORT_TERM_LIST_ALL[i] == 2: arrow = pg.ArrowItem(pos=(i, self.datas[i]['high']),size=7,tipAngle=55,tailLen=3,tailWidth=4 ,angle=-90, brush=(225, 0, 225),pen=({'color': "FF00FF", 'width': 1})) self.pwKL.addItem(arrow) self.KLINE_SHORT_TERM_LIST_ALL_arrows.append(arrow) last_x=-1 #上一个x last_y=-1 #上一个y last_v=-1 for i in range(len(self.KLINE_SHORT_TERM_LIST_ALL)): if self.KLINE_SHORT_TERM_LIST_ALL[i] != 0 : if last_x!=- 1 and last_y!=-1 and \ ((last_v == 1 and self.KLINE_SHORT_TERM_LIST_ALL[i] == 2) and self.KLINE_LOW[last_x]<self.KLINE_HIGH[i]) or \ ((last_v == 2 and self.KLINE_SHORT_TERM_LIST_ALL[i] == 1) and self.KLINE_HIGH[last_x]>self.KLINE_LOW[i]) or \ ((last_v == 1 and self.KLINE_SHORT_TERM_LIST_ALL[i] == 1)) or \ ((last_v == 2 and self.KLINE_SHORT_TERM_LIST_ALL[i] == 2)) : curve = pg.PlotCurveItem(x=np.array([last_x,i]),y=np.array([last_y,self.datas[i]['low'] if self.KLINE_SHORT_TERM_LIST_ALL[i]==1 else self.datas[i]['high']]),name='duo',pen=({'color': "FF00FF", 'width': 1})) self.pwKL.addItem(curve) self.KLINE_SHORT_TERM_LIST_ALL_curves.append(curve) last_x =i if self.KLINE_SHORT_TERM_LIST_ALL[i] ==1 : last_y=self.datas[i]['low'] elif self.KLINE_SHORT_TERM_LIST_ALL[i] ==2 : last_y=self.datas[i]['high'] last_v=self.KLINE_SHORT_TERM_LIST_ALL[i] #----------------------------------------------------------------------
Example #25
Source File: uiKLine.py From uiKLine with MIT License | 5 votes |
def plotIndex_LIMIT (self): """画指标""" # 检查是否有数据 if len(self.KLINE_SHORT_TERM_LIST_LIMIT)==0 : self.refresh() return for arrow in self.KLINE_SHORT_TERM_LIST_LIMIT_arrows: self.pwKL.removeItem(arrow) for curves in self.KLINE_SHORT_TERM_LIST_LIMIT_curves: self.pwKL.removeItem(curves) for i in range(len(self.KLINE_SHORT_TERM_LIST_LIMIT)): if self.KLINE_SHORT_TERM_LIST_LIMIT[i] == 1: arrow = pg.ArrowItem(pos=(i, self.datas[i]['low']), size=7,tipAngle=55,tailLen=3,tailWidth=4, angle=90, brush=(34, 139, 34),pen=({'color': "228B22", 'width': 1})) self.pwKL.addItem(arrow) self.KLINE_SHORT_TERM_LIST_LIMIT_arrows.append(arrow) if self.KLINE_SHORT_TERM_LIST_LIMIT[i] == 2: arrow = pg.ArrowItem(pos=(i, self.datas[i]['high']),size=7,tipAngle=55,tailLen=3,tailWidth=4 ,angle=-90, brush=(34, 139, 34),pen=({'color': "228B22", 'width': 1})) self.pwKL.addItem(arrow) self.KLINE_SHORT_TERM_LIST_LIMIT_arrows.append(arrow) last_x=-1 #上一个x last_y=-1 #上一个y last_v=-1 for i in range(len(self.KLINE_SHORT_TERM_LIST_LIMIT)): if self.KLINE_SHORT_TERM_LIST_LIMIT[i] != 0 : if last_x!=-1 and last_y!=-1 and last_v!=self.KLINE_SHORT_TERM_LIST_LIMIT[i] and\ ((last_v == 1 and self.KLINE_SHORT_TERM_LIST_LIMIT[i] == 2) and self.KLINE_LOW[last_x]<self.KLINE_HIGH[i]) or\ ((last_v == 2 and self.KLINE_SHORT_TERM_LIST_LIMIT[i] == 1) and self.KLINE_HIGH[last_x]>self.KLINE_LOW[i]): curve = pg.PlotCurveItem(x=np.array([last_x,i]),y=np.array([last_y,self.datas[i]['low'] if self.KLINE_SHORT_TERM_LIST_LIMIT[i]==1 else self.datas[i]['high']]),name='duo',pen=({'color': "228B22", 'width': 1})) self.pwKL.addItem(curve) self.KLINE_SHORT_TERM_LIST_LIMIT_curves.append(curve) last_x =i if self.KLINE_SHORT_TERM_LIST_LIMIT[i] ==1 : last_y=self.datas[i]['low'] elif self.KLINE_SHORT_TERM_LIST_LIMIT[i] ==2 : last_y=self.datas[i]['high'] last_v=self.KLINE_SHORT_TERM_LIST_LIMIT[i] #----------------------------------------------------------------------
Example #26
Source File: monitor_control.py From stytra with GNU General Public License v3.0 | 4 votes |
def __init__(self, *args, display_size=(1280, 800), display, **kwargs): super().__init__(*args, **kwargs) self.display = display self.view_box = pg.ViewBox(invertY=True, lockAspect=1, enableMouse=False) self.addItem(self.view_box) self.roi_box = pg.ROI( maxBounds=QRectF(0, 0, display_size[0], display_size[1]), size=display.size, pos=display.pos, ) self.roi_box.addScaleHandle([0, 0], [1, 1]) self.roi_box.addScaleHandle([1, 1], [0, 0]) self.roi_box.sigRegionChanged.connect(self.set_param_val) self.display.sig_param_changed.connect(self.set_roi) self.view_box.addItem(self.roi_box) self.view_box.setRange( QRectF(0, 0, display_size[0], display_size[1]), update=True, disableAutoRange=True, ) self.view_box.addItem( pg.ROI( pos=(1, 1), size=(display_size[0] - 1, display_size[1] - 1), movable=False, pen=(80, 80, 80), ) ) self.calibration_points = pg.ScatterPlotItem(pen=(255, 0, 0), brush=None) self.calibration_frame = pg.PlotCurveItem( brush=(120, 10, 10), pen=(200, 10, 10), fill_level=1 ) self.camera_image = pg.ImageItem() self.view_box.addItem(self.calibration_frame) self.view_box.addItem(self.camera_image) self.view_box.addItem(self.calibration_points) self.setting_param_val = False self.set_param_val()
Example #27
Source File: fishplots.py From stytra with GNU General Public License v3.0 | 4 votes |
def __init__(self, acc: QueueDataAccumulator, i_fish=0, n_bouts=10, n_save_max=300): super().__init__() self.title = "Bout shape" self.acc = acc self.bouts = deque() self.i_fish = i_fish self.processed_index = 0 self.detection_params = Parametrized( params=dict( threshold=Param(0.2, (0.01, 5.0)), n_without_crossing=Param(5, (0, 10)), pad_before=Param(5, (0, 20)), pad_after=Param(5, (0, 20)), min_bout_len=Param(1, (1, 30)), ) ) self.n_bouts = n_bouts self.old_coords = None self.i_curve = 0 self.n_save_max = n_save_max self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.btn_editparam = QPushButton("Detection parameters") self.btn_editparam.clicked.connect(self.edit_params) self.layout().addWidget(self.btn_editparam) self.wnd_params = None self.vmax = 0 self.lbl_vmax = QLabel() self.layout().addWidget(self.lbl_vmax) self.display_widget = pg.GraphicsLayoutWidget() self.layout().addWidget(self.display_widget) self.vb_display = pg.ViewBox() self.vb_display.setAspectLocked(True, 1) self.vb_display.setRange(xRange=[-1, 5], disableAutoRange=True) self.vb_display.invertY(True) self.display_widget.addItem(self.vb_display) self.bout_curves = [ pg.PlotCurveItem(connect="finite") for _ in range(self.n_bouts) ] self.colors = np.zeros(self.n_bouts) self.decay_constant = 0.99 self.bout_coords = None self.bout_state = BoutState(0, 0.0, 0, 0, 0) for c in self.bout_curves: self.vb_display.addItem(c)
Example #28
Source File: crosscorrelogramviewer.py From tridesclous with MIT License | 4 votes |
def refresh(self): self.grid.clear() if self.ccg is None: return visibles = [ ] for k in self.controller.positive_cluster_labels: if self.controller.cluster_visible[k]: visibles.append(k) visibles = visibles[:self.params['max_visible']] n = len(visibles) bins = self.bins * 1000. #to ms labels = self.controller.positive_cluster_labels.tolist() for r in range(n): for c in range(r, n): i = labels.index(visibles[r]) j = labels.index(visibles[c]) count = self.ccg[i, j, :] plot = pg.PlotItem() if not self.params['display_axis']: plot.hideAxis('bottom') plot.hideAxis('left') if r==c: k = visibles[r] color = self.controller.qcolors[k] else: color = (120,120,120,120) curve = pg.PlotCurveItem(bins, count, stepMode=True, fillLevel=0, brush=color, pen=color) plot.addItem(curve) self.grid.addItem(plot, row=r, col=c) #~ plt1.plot(x, y, stepMode=True, fillLevel=0, brush=(0,0,255,150))
Example #29
Source File: traceviewer.py From tridesclous with MIT License | 4 votes |
def initialize_plot(self): self.viewBox = MyViewBox() self.plot = pg.PlotItem(viewBox=self.viewBox) self.graphicsview.setCentralItem(self.plot) self.plot.hideButtons() self.plot.showAxis('left', False) self.viewBox.gain_zoom.connect(self.gain_zoom) self.viewBox.xsize_zoom.connect(self.xsize_zoom) self.visible_channels = np.zeros(self.controller.nb_channel, dtype='bool') self.max_channel = min(16, self.controller.nb_channel) #~ self.max_channel = min(5, self.controller.nb_channel) if self.controller.nb_channel>self.max_channel: self.visible_channels[:self.max_channel] = True self.scroll_chan.show() self.scroll_chan.setMinimum(0) self.scroll_chan.setMaximum(self.controller.nb_channel-self.max_channel) self.scroll_chan.setPageStep(self.max_channel) else: self.visible_channels[:] = True self.scroll_chan.hide() self.signals_curve = pg.PlotCurveItem(pen='#7FFF00', connect='finite') self.plot.addItem(self.signals_curve) self.scatter = pg.ScatterPlotItem(size=10, pxMode = True) self.plot.addItem(self.scatter) self.scatter.sigClicked.connect(self.scatter_item_clicked) self.channel_labels = [] self.threshold_lines =[] for i, chan_name in enumerate(self.controller.channel_names): #TODO label channels label = pg.TextItem('{}: {}'.format(i, chan_name), color='#FFFFFF', anchor=(0, 0.5), border=None, fill=pg.mkColor((128,128,128, 180))) self.plot.addItem(label) self.channel_labels.append(label) for i in range(self.max_channel): tc = pg.InfiniteLine(angle = 0., movable = False, pen = pg.mkPen(color=(128,128,128, 120))) tc.setPos(0.) self.threshold_lines.append(tc) self.plot.addItem(tc) tc.hide() pen = pg.mkPen(color=(128,0,128, 120), width=3, style=QT.Qt.DashLine) self.selection_line = pg.InfiniteLine(pos = 0., angle=90, movable=False, pen = pen) self.plot.addItem(self.selection_line) self.selection_line.hide() self._initialize_plot() self.gains = None self.offsets = None
Example #30
Source File: relativity.py From tf-pose with Apache License 2.0 | 4 votes |
def getCurve(self, ref=True): if ref is False: data = self.inertData else: data = self.refData[1:] x = data['x'] y = data['t'] curve = pg.PlotCurveItem(x=x, y=y, pen=self.pen) #x = self.data['x'] - ref.data['x'] #y = self.data['t'] step = 1.0 #mod = self.data['pt'] % step #inds = np.argwhere(abs(mod[1:] - mod[:-1]) > step*0.9) inds = [0] pt = data['pt'] for i in range(1,len(pt)): diff = pt[i] - pt[inds[-1]] if abs(diff) >= step: inds.append(i) inds = np.array(inds) #t = self.data['t'][inds] #x = self.data['x'][inds] pts = [] for i in inds: x = data['x'][i] y = data['t'][i] if i+1 < len(data): dpt = data['pt'][i+1]-data['pt'][i] dt = data['t'][i+1]-data['t'][i] else: dpt = 1 if dpt > 0: c = pg.mkBrush((0,0,0)) else: c = pg.mkBrush((200,200,200)) pts.append({'pos': (x, y), 'brush': c}) points = pg.ScatterPlotItem(pts, pen=self.pen, size=7) return curve, points