当前位置: 首页>>代码示例>>Python>>正文


Python pyqtgraph.TextItem方法代码示例

本文整理汇总了Python中pyqtgraph.TextItem方法的典型用法代码示例。如果您正苦于以下问题:Python pyqtgraph.TextItem方法的具体用法?Python pyqtgraph.TextItem怎么用?Python pyqtgraph.TextItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyqtgraph的用法示例。


在下文中一共展示了pyqtgraph.TextItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def __init__(self,parent):
        """Constructor"""
        self.__view = parent
        
        super(Crosshair, self).__init__()
        self.__vLine = pg.InfiniteLine(angle=90, movable=False)
        self.__hLine = pg.InfiniteLine(angle=0, movable=False)
        self.__textPrice = pg.TextItem('price')
        self.__textDate = pg.TextItem('date')
        
        #mid 在y轴动态跟随最新价显示最新价和最新时间
        self.__textLastPrice = pg.TextItem('lastTickPrice')    
        
        view = self.__view
        
        view.addItem(self.__textDate, ignoreBounds=True)
        view.addItem(self.__textPrice, ignoreBounds=True)        
        view.addItem(self.__vLine, ignoreBounds=True)
        view.addItem(self.__hLine, ignoreBounds=True)    
        view.addItem(self.__textLastPrice, ignoreBounds=True)     
        self.proxy = pg.SignalProxy(view.scene().sigMouseMoved, rateLimit=60, slot=self.__mouseMoved)        
        
    #---------------------------------------------------------------------- 
开发者ID:zhengwsh,项目名称:InplusTrader_Linux,代码行数:25,代码来源:uiCrosshair.py

示例2: _init_label

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def _init_label(self) -> None:
        """
        Create label objects on axis.
        """
        self._y_labels: Dict[str, pg.TextItem] = {}
        for plot_name, plot in self._plots.items():
            label = pg.TextItem(
                plot_name, fill=CURSOR_COLOR, color=BLACK_COLOR)
            label.hide()
            label.setZValue(2)
            label.setFont(NORMAL_FONT)
            plot.addItem(label, ignoreBounds=True)
            self._y_labels[plot_name] = label

        self._x_label: pg.TextItem = pg.TextItem(
            "datetime", fill=CURSOR_COLOR, color=BLACK_COLOR)
        self._x_label.hide()
        self._x_label.setZValue(2)
        self._x_label.setFont(NORMAL_FONT)
        plot.addItem(self._x_label, ignoreBounds=True) 
开发者ID:nicai0609,项目名称:Python-CTPAPI,代码行数:22,代码来源:candle_demo.py

示例3: _init_info

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def _init_info(self) -> None:
        """
        """
        self._infos: Dict[str, pg.TextItem] = {}
        for plot_name, plot in self._plots.items():
            info = pg.TextItem(
                "info",
                color=CURSOR_COLOR,
                border=CURSOR_COLOR,
                fill=BLACK_COLOR
            )
            info.hide()
            info.setZValue(2)
            info.setFont(NORMAL_FONT)
            plot.addItem(info)  # , ignoreBounds=True)
            self._infos[plot_name] = info 
开发者ID:nicai0609,项目名称:Python-CTPAPI,代码行数:18,代码来源:candle_demo.py

示例4: __init__

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def __init__(self, ax, color):
        self.ax = ax
        self.x = 0
        self.y = 0
        self.clamp_x = 0
        self.clamp_y = 0
        self.infos = []
        pen = pg.mkPen(color=color, style=QtCore.Qt.CustomDashLine, dash=[7, 7])
        self.vline = pg.InfiniteLine(angle=90, movable=False, pen=pen)
        self.hline = pg.InfiniteLine(angle=0, movable=False, pen=pen)
        self.xtext = pg.TextItem(color=color, anchor=(0,1))
        self.ytext = pg.TextItem(color=color, anchor=(0,0))
        self.vline.setZValue(50)
        self.hline.setZValue(50)
        self.xtext.setZValue(50)
        self.ytext.setZValue(50)
        ax.addItem(self.vline, ignoreBounds=True)
        ax.addItem(self.hline, ignoreBounds=True)
        ax.addItem(self.xtext, ignoreBounds=True)
        ax.addItem(self.ytext, ignoreBounds=True) 
开发者ID:highfestiva,项目名称:finplot,代码行数:22,代码来源:__init__.py

示例5: generate_picture

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def generate_picture(self, bounding_rect):
        rows = self.getrows(bounding_rect)
        if len(rows) > lod_labels: # don't even generate when there's too many of them
            self.clear_items(list(self.text_items.keys()))
            return
        drops = set(self.text_items.keys())
        created = 0
        for x,t,y,txt in rows:
            txt = str(txt)
            key = '%s:%.8f' % (t, y)
            if key in self.text_items:
                item = self.text_items[key]
                item.setText(txt)
                item.setPos(x, y)
                drops.remove(key)
            else:
                self.text_items[key] = item = pg.TextItem(txt, color=self.color, anchor=self.anchor)
                item.setPos(x, y)
                item.setParentItem(self)
                created += 1
        if created > 0 or self.dirty: # only reduce cache if we've added some new or updated
            self.clear_items(drops) 
开发者ID:highfestiva,项目名称:finplot,代码行数:24,代码来源:__init__.py

示例6: __init__

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def __init__(self, parent=None):
        pyqtgraph.setConfigOption('background', 'w') #before loading widget
        super(ExampleApp, self).__init__(parent)
        self.setupUi(self)
        self.grECG.plotItem.showGrid(True, True, 0.7)
        self.btnSave.clicked.connect(self.saveFig)
        self.btnSite.clicked.connect(self.website)
        stamp="DIY ECG by Scott Harden"
        self.stamp = pyqtgraph.TextItem(stamp,anchor=(-.01,1),color=(150,150,150),
                                        fill=pyqtgraph.mkBrush('w'))
        self.ear = swhear.Ear(chunk=int(100)) # determines refresh rate
        # optionally you can manually set the audio input device to use like this:
        # self.ear = swhear.Ear(chunk=int(100), device=5) # use audio input device 5
        if len(self.ear.valid_input_devices()):
            self.ear.stream_start()
            self.lblDevice.setText(self.ear.msg)
            self.update() 
开发者ID:swharden,项目名称:diyECG-1opAmp,代码行数:19,代码来源:go.py

示例7: setTexts

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def setTexts(self, text):
        for i in self.textItems:
            i.scene().removeItem(i)
        self.textItems = []
        for t in text:
            item = pg.TextItem(t)
            self.textItems.append(item)
            item.setParentItem(self) 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:10,代码来源:CustomGraphItem.py

示例8: __add_items_to_plot

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def __add_items_to_plot(self, len_plot, min_audio, max_audio):
        """
        Adds a region selector item and vertical line for to the waveform plot.

        :param len_plot: (int) Number of samples in plotted waveform array.
        :param min_audio: (float) The minimum value of plotted waveform array.
        :param max_audio: (float) The maximum value of plotted waveform array.
        """

        # Create a waveform region item and add it to waveform plot
        pos_wf_x_max = len_plot * 0.05  # Region item focuses on the 5% of
        # waveform plot.
        self.region_wf = WaveformRegionItem(values=[0, pos_wf_x_max],
                                            brush=WAVEFORM_BRUSH,
                                            bounds=[0., len_plot])

        # Creating a cursor with pyqtgraph.ROI
        self.vline_wf = pg.ROI(pos=[0, min_audio],
                               size=[0, max_audio - min_audio],
                               angle=0, pen=WAVEFORM_VLINE)

        # add items to waveform plot
        self.waveform.addItem(self.region_wf)
        self.waveform.addItem(self.vline_wf)

        # text item
        self.section_label = pg.TextItem(text='')
        self.waveform.addItem(self.section_label) 
开发者ID:MTG,项目名称:dunya-desktop,代码行数:30,代码来源:waveformwidget.py

示例9: refresh

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def refresh(self, v=None):
        self.plot.clear()
        
        flip_bottom_up = self.checkbox.checkState()
        
        
        chan_grp = int(self.combo_chan_grp.currentText())
        channel_group = self.channel_groups[chan_grp]
        if channel_group['geometry'] is None:
            return
        
        
        geometry = [ channel_group['geometry'][chan] for chan in channel_group['channels'] ]
        geometry = np.array(geometry, dtype='float64')
        
        if flip_bottom_up:
            geometry[:, 1] *= -1.
        
        for c, chan in enumerate(channel_group['channels']):
            x, y = geometry[c]
            
            #~ name = '{}: {}'.format(c, chan)
            name = '{}'.format(chan)
            itemtxt = pg.TextItem(name, anchor=(.5,.5))
            self.plot.addItem(itemtxt)
            itemtxt.setPos(x, y)

        margin = 100
        
        self.plot.setXRange(np.min(geometry[:, 0])-margin, np.max(geometry[:, 0])+margin)
        self.plot.setYRange(np.min(geometry[:, 1])-margin, np.max(geometry[:, 1])+margin)
            

    #~ for c, chan in enumerate(channels):
        #~ x, y = geometry[c]
        #~ ax.plot([x], [y], marker='o', color='r')
        #~ ax.text(x, y, '{}: {}'.format(c, chan),  size=20) 
开发者ID:tridesclous,项目名称:tridesclous,代码行数:39,代码来源:probegeometryview.py

示例10: refresh

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def refresh(self):
        if self.similarity is None:
            self.image.hide()
            return
        
        _max = np.max(self.similarity)
        
        cluster_visible = self.controller.cluster_visible
        visibles = [c for c, v in self.controller.cluster_visible.items() if v and c>=0]
        
        labels = self.controller.spike_label[self.controller.some_peaks_index]
        keep_ind,  = np.nonzero(np.in1d(labels, visibles))
        keep_label = labels[keep_ind]
        order = np.argsort(keep_label)
        keep_ind = keep_ind[order]
        
        if keep_ind.size>0:
            s = self.similarity[keep_ind,:][:, keep_ind]
            self.image.setImage(s, lut=self.lut, levels=[0, _max])
            self.image.show()
            self.plot.setXRange(0, s.shape[0])
            self.plot.setYRange(0, s.shape[1])
            
            for item in self._text_items:
                self.plot.removeItem(item)
            
            pos = 0
            for k in np.sort(visibles):
                n = np.sum(keep_label==k)
                for i in range(2):
                    item = pg.TextItem(text='{}'.format(k), color='#FFFFFF', anchor=(0.5, 0.5), border=None)
                    self.plot.addItem(item)
                    if i==0:
                        item.setPos(pos+n/2., 0)
                    else:
                        item.setPos(0, pos+n/2.)
                    self._text_items.append(item)
                pos += n
                
        else:
            self.image.hide() 
开发者ID:tridesclous,项目名称:tridesclous,代码行数:43,代码来源:similarity.py

示例11: proc_ROI

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def proc_ROI(self):
        stat0 = []
        if self.extracted:
            for t, s in zip(self.scatter, self.tlabel):
                self.p0.removeItem(s)
                self.p0.removeItem(t)
        self.scatter = []
        self.tlabel = []
        for n in range(self.nROIs):
            ellipse = self.ROIs[n].ellipse
            yrange = self.ROIs[n].yrange
            xrange = self.ROIs[n].xrange
            x, y = np.meshgrid(xrange, yrange)
            ypix = y[ellipse].flatten()
            xpix = x[ellipse].flatten()
            lam = np.ones(ypix.shape)
            stat0.append({'ypix': ypix, 'xpix': xpix, 'lam': lam, 'npix': ypix.size})
            self.tlabel.append(pg.TextItem(str(n), self.ROIs[n].color, anchor=(0, 0)))
            self.tlabel[-1].setPos(xpix.mean(), ypix.mean())
            self.p0.addItem(self.tlabel[-1])
            self.scatter.append(pg.ScatterPlotItem([xpix.mean()], [ypix.mean()],
                                                   pen=self.ROIs[n].color, symbol='+'))
            self.p0.addItem(self.scatter[-1])
        if not os.path.isfile(self.parent.ops['reg_file']):
            self.parent.ops['reg_file'] = os.path.join(self.parent.basename, 'data.bin')

        F, Fneu, F_chan2, Fneu_chan2, spks, ops, stat = masks_and_traces(self.parent.ops, stat0, self.parent.stat)
        print(spks.shape)
        # print('After', stat[0].keys())
        # print('Orig', self.parent.stat[0].keys())
        self.Fcell = F
        self.Fneu = Fneu
        self.F_chan2 = F_chan2
        self.Fneu_chan2 = Fneu_chan2
        self.Spks = spks
        self.plot_trace()
        self.extracted = True
        self.new_stat = stat
        self.closeGUI.setEnabled(True) 
开发者ID:MouseLand,项目名称:suite2p,代码行数:41,代码来源:drawroi.py

示例12: __init__

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def __init__(self, parent=None):
        super(MyWindow, self).__init__(parent)
        self.setupUi(self)
        x = np.linspace(-100, 100, 1000)
        data = np.sin(x) / x
        self.graphicsView.plot(data, pen=(255, 255, 255, 200))
        self.label = pg.TextItem(text="横坐标:{}".format(0))
        self.graphicsView.addItem(self.label)
        self.setMouseTracking(True)
        self.graphicsView.scene().sigMouseMoved.connect(self.onMouseMoved) 
开发者ID:PyQt5,项目名称:PyQt,代码行数:12,代码来源:mouseFlow.py

示例13: addSegment

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def addSegment(self, h1, h2, index=None):
        super().addSegment(h1, h2, index)
        text = pg.TextItem(color=draw_line_color)
        text.setZValue(50)
        text.segment = self.segments[-1 if index is None else index]
        if index is None:
            self.texts.append(text)
        else:
            self.texts.insert(index, text)
        self.update_text(text)
        self.vb.addItem(text, ignoreBounds=True) 
开发者ID:highfestiva,项目名称:finplot,代码行数:13,代码来源:__init__.py

示例14: add_text

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def add_text(pos, s, color=draw_line_color, anchor=(0,0), ax=None):
    ax = _create_plot(ax=ax, maximize=False)
    text = pg.TextItem(s, color=color, anchor=anchor)
    text.setPos(_pdtime2index(ax, pd.Series([pos[0]]))[0], pos[1])
    text.setZValue(50)
    text.ax = ax
    ax.addItem(text, ignoreBounds=True)
    return text 
开发者ID:highfestiva,项目名称:finplot,代码行数:10,代码来源:__init__.py

示例15: _plot_anchor

# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import TextItem [as 别名]
def _plot_anchor(self, x, y, anchor_id, distance, display_mode, is_active):
        if is_active:
            brush = PlotWrapper.ANCHOR_BRUSH
        else:
            brush = PlotWrapper.ANCHOR_BRUSH_INVALID

        size = PlotWrapper.ANCHOR_SIZE
        font_size = self.LABEL_SIZE
        if display_mode is DisplayMode.identify_anchor:
            if distance < PlotWrapper.VICINITY_DISTANCE:
                brush = self._mix_brushes(
                    brush,
                    PlotWrapper.HIGHLIGHT_ANCHOR_BRUSH,
                    distance / PlotWrapper.VICINITY_DISTANCE)

            if distance < PlotWrapper.HIGHLIGHT_DISTANCE:
                brush = PlotWrapper.HIGHLIGHT_ANCHOR_BRUSH
                size = PlotWrapper.HIGHLIGHT_SIZE
                font_size = self.LABEL_HIGHLIGHT_SIZE

        self.widget.plot([x], [y], pen=None, symbolBrush=brush,
                         symbolSize=size)

        text = pg.TextItem(text="{}".format(anchor_id))
        font = QFont("Helvetica", font_size)
        text.setFont(font)
        self.widget.addItem(text)
        text.setPos(x, y) 
开发者ID:bitcraze,项目名称:crazyflie-clients-python,代码行数:30,代码来源:locopositioning_tab.py


注:本文中的pyqtgraph.TextItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。