本文整理汇总了Python中pyqtgraph.PlotCurveItem方法的典型用法代码示例。如果您正苦于以下问题:Python pyqtgraph.PlotCurveItem方法的具体用法?Python pyqtgraph.PlotCurveItem怎么用?Python pyqtgraph.PlotCurveItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph
的用法示例。
在下文中一共展示了pyqtgraph.PlotCurveItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawHistogram
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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
示例2: plot
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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
示例3: test_PlotCurveItem
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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.")
示例4: initialize_plot
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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()
示例5: refresh
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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)
示例6: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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
示例7: initTracePlot
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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()
示例8: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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()
示例9: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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
示例10: initplotKline
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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)
#----------------------------------------------------------------------
示例11: plotIndex_LIMIT
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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]
#----------------------------------------------------------------------
示例12: plotIndex_ALL
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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]
#----------------------------------------------------------------------
示例13: plotIndex_FIRST
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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]
#----------------------------------------------------------------------
示例14: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
def __init__(self, *args, **kwds):
self.hdf5 = None
self.limit = 10000 # maximum number of samples to be plotted
pg.PlotCurveItem.__init__(self, *args, **kwds)
示例15: _initialize_plot
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotCurveItem [as 别名]
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)