本文整理汇总了Python中pyqtgraph.PlotWidget方法的典型用法代码示例。如果您正苦于以下问题:Python pyqtgraph.PlotWidget方法的具体用法?Python pyqtgraph.PlotWidget怎么用?Python pyqtgraph.PlotWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph
的用法示例。
在下文中一共展示了pyqtgraph.PlotWidget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [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
示例2: setupUi
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(400, 300)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.sizeSpin = QtGui.QSpinBox(Form)
self.sizeSpin.setProperty("value", 10)
self.sizeSpin.setObjectName(_fromUtf8("sizeSpin"))
self.gridLayout.addWidget(self.sizeSpin, 1, 1, 1, 1)
self.pixelModeCheck = QtGui.QCheckBox(Form)
self.pixelModeCheck.setObjectName(_fromUtf8("pixelModeCheck"))
self.gridLayout.addWidget(self.pixelModeCheck, 1, 3, 1, 1)
self.label = QtGui.QLabel(Form)
self.label.setObjectName(_fromUtf8("label"))
self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
self.plot = PlotWidget(Form)
self.plot.setObjectName(_fromUtf8("plot"))
self.gridLayout.addWidget(self.plot, 0, 0, 1, 4)
self.randCheck = QtGui.QCheckBox(Form)
self.randCheck.setObjectName(_fromUtf8("randCheck"))
self.gridLayout.addWidget(self.randCheck, 1, 2, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
示例3: setupUi
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.sizeSpin = QtGui.QSpinBox(Form)
self.sizeSpin.setProperty("value", 10)
self.sizeSpin.setObjectName("sizeSpin")
self.gridLayout.addWidget(self.sizeSpin, 1, 1, 1, 1)
self.pixelModeCheck = QtGui.QCheckBox(Form)
self.pixelModeCheck.setObjectName("pixelModeCheck")
self.gridLayout.addWidget(self.pixelModeCheck, 1, 3, 1, 1)
self.label = QtGui.QLabel(Form)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
self.plot = PlotWidget(Form)
self.plot.setObjectName("plot")
self.gridLayout.addWidget(self.plot, 0, 0, 1, 4)
self.randCheck = QtGui.QCheckBox(Form)
self.randCheck.setObjectName("randCheck")
self.gridLayout.addWidget(self.randCheck, 1, 2, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
示例4: test_PlotWidget
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def test_PlotWidget():
def mkobjs(*args, **kwds):
w = pg.PlotWidget(*args, **kwds)
data = pg.np.array([1,5,2,4,3])
c = w.plot(data, name='stuff')
w.addLegend()
# test that connections do not keep objects alive
w.plotItem.vb.sigRangeChanged.connect(mkrefs)
app.focusChanged.connect(w.plotItem.vb.invertY)
# return weakrefs to a bunch of objects that should die when the scope exits.
return mkrefs(w, c, data, w.plotItem, w.plotItem.vb, w.plotItem.getMenu(), w.plotItem.getAxis('left'))
for i in range(5):
assert_alldead(mkobjs())
示例5: initplotKline
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def initplotKline(self):
"""Kline"""
self.pw2 = pg.PlotWidget(name='Plot2') # K线图
self.vbl_2.addWidget(self.pw2)
self.pw2.setDownsampling(mode='peak')
self.pw2.setClipToView(True)
self.curve5 = self.pw2.plot()
self.curve6 = self.pw2.plot()
self.candle = self.CandlestickItem(self.listBar)
self.pw2.addItem(self.candle)
## Draw an arrowhead next to the text box
# self.arrow = pg.ArrowItem()
# self.pw2.addItem(self.arrow)
#----------------------------------------------------------------------
示例6: init
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def init(self, name, input):
self.plot = pg.PlotWidget(title=name)
self.plot.block = self
self.plot.setLabel('bottom', 'Frequency', units='Hz')
self.bars = pg.BarGraphItem()
self.setup_range()
# TODO: Better autoranging features
#self.plot.enableAutoRange('xy', False)
self.plot.setYRange(0, self.yrange)
self.input = input
self.name = name
示例7: init
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def init(self, history=512, autoscale=True):
self.widget = pg.PlotWidget()
self.widget.block = self
self.gr_block.set_history(history)
self.plot = self.widget.plot()
self.plot.setPen(QtGui.QColor(self.input.color))
#self.widget.setYRange(*self.yrange)
self.widget.enableAutoRange('y', 0.95 if autoscale else False)
self.buffer = []
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.updateGUI)
self.timer.start(100)
示例8: init
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def init(self, history=512, autoscale=True):
self.widget = pg.PlotWidget()
self.widget.block = self
self.gr_block.set_history(history)
self.plot = self.widget.plot()
self.plot.setPen(QtGui.QColor(self.input.color))
#self.widget.setYRange(*self.yrange)
self.widget.enableAutoRange('y', 0.95 if autoscale else False)
self.buffer = []
self.timer = pg.QtCore.QTimer()
self.timer.timeout.connect(self.updateGUI)
self.timer.start(100)
示例9: __init__
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def __init__(self):
super().__init__()
self.xaxis = DateAxis(orientation='bottom')
self.xaxis.setStyle(tickTextOffset=7, textFillLimits=[(0, 0.80)])
self.yaxis = PriceAxis()
self.layout = QtGui.QVBoxLayout(self)
self.layout.setContentsMargins(0, 0, 0, 0)
self.chart = pg.PlotWidget(
axisItems={'bottom': self.xaxis, 'right': self.yaxis},
enableMenu=False,
)
self.chart.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
self.chart.getPlotItem().setContentsMargins(*CHART_MARGINS)
self.chart.showGrid(x=True, y=True)
self.chart.hideAxis('left')
self.chart.showAxis('right')
self.chart.setCursor(QtCore.Qt.BlankCursor)
self.chart.sigXRangeChanged.connect(self._update_yrange_limits)
self.layout.addWidget(self.chart)
示例10: initUI
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def initUI(self):
self.pw = pg.PlotWidget()
self.layout = pg.GraphicsLayout(border=(100, 100, 100))
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.layout.setBorder(color=(255, 255, 255, 255), width=0.8)
self.layout.setZValue(0)
self.layout.setMinimumHeight(140)
self.pw.setCentralWidget(self.layout)
# 设置横坐标
xdict = {}
self.axisTime = MyStringAxis(xdict, orientation='bottom')
# 初始化资金曲线
self.initPlotFund()
# 十字光标
self.crosshair = Crosshair(self.pw, self)
self.vbox = QtWidgets.QVBoxLayout()
self.vbox.addWidget(self.pw)
self.setLayout(self.vbox)
self.initCompleted = True
self.oldSize = self.rect().height()
示例11: initUI
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def initUI(self):
self.pw = pg.PlotWidget()
self.layout = pg.GraphicsLayout(border=(10, 10, 10))
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.layout.setBorder(color=(255, 255, 255, 255), width=0.8)
self.layout.setZValue(0)
self.layout.setMinimumHeight(140)
self.pw.setCentralWidget(self.layout)
# 设置横坐标
xdict = {}
self.axisTime = MyStringAxis(xdict, orientation='bottom')
# 初始化资金曲线
self.initPlotGraph()
# 十字光标
self.crosshair = GCrosshair(self.pw, self)
self.vbox = QVBoxLayout()
self.vbox.addWidget(self.pw)
self.setLayout(self.vbox)
self.initCompleted = True
self.oldSize = self.rect().height()
示例12: test_getViewWidget_deleted
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def test_getViewWidget_deleted():
view = pg.PlotWidget()
item = pg.InfiniteLine()
view.addItem(item)
assert item.getViewWidget() is view
# Arrange to have Qt automatically delete the view widget
obj = pg.QtGui.QWidget()
view.setParent(obj)
del obj
gc.collect()
assert not pg.Qt.isQObjectAlive(view)
assert item.getViewWidget() is None
#if __name__ == '__main__':
#view = pg.PlotItem()
#vref = weakref.ref(view)
#item = pg.InfiniteLine()
#view.addItem(item)
#del view
#gc.collect()
示例13: setupUi
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(993, 692)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.horizontalLayout = QtGui.QHBoxLayout(self.centralwidget)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.pbLevel = QtGui.QProgressBar(self.centralwidget)
self.pbLevel.setMaximum(1000)
self.pbLevel.setProperty("value", 123)
self.pbLevel.setTextVisible(False)
self.pbLevel.setOrientation(QtCore.Qt.Vertical)
self.pbLevel.setObjectName(_fromUtf8("pbLevel"))
self.horizontalLayout.addWidget(self.pbLevel)
self.frame = QtGui.QFrame(self.centralwidget)
self.frame.setFrameShape(QtGui.QFrame.NoFrame)
self.frame.setFrameShadow(QtGui.QFrame.Plain)
self.frame.setObjectName(_fromUtf8("frame"))
self.verticalLayout = QtGui.QVBoxLayout(self.frame)
self.verticalLayout.setMargin(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.label = QtGui.QLabel(self.frame)
self.label.setObjectName(_fromUtf8("label"))
self.verticalLayout.addWidget(self.label)
self.grFFT = PlotWidget(self.frame)
self.grFFT.setObjectName(_fromUtf8("grFFT"))
self.verticalLayout.addWidget(self.grFFT)
self.label_2 = QtGui.QLabel(self.frame)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.verticalLayout.addWidget(self.label_2)
self.grPCM = PlotWidget(self.frame)
self.grPCM.setObjectName(_fromUtf8("grPCM"))
self.verticalLayout.addWidget(self.grPCM)
self.horizontalLayout.addWidget(self.frame)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例14: setupUi
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(820, 650)
MainWindow.setAutoFillBackground(False)
MainWindow.setDocumentMode(False)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.horizontalLayout = QtGui.QHBoxLayout()
self.horizontalLayout.setContentsMargins(-1, -1, 0, 0)
self.horizontalLayout.setSpacing(10)
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
self.btnAdd = QtGui.QPushButton(self.centralwidget)
self.btnAdd.setObjectName(_fromUtf8("btnAdd"))
self.horizontalLayout.addWidget(self.btnAdd)
self.chkMore = QtGui.QCheckBox(self.centralwidget)
self.chkMore.setObjectName(_fromUtf8("chkMore"))
self.horizontalLayout.addWidget(self.chkMore)
self.verticalLayout.addLayout(self.horizontalLayout)
self.grPlot = PlotWidget(self.centralwidget)
self.grPlot.setObjectName(_fromUtf8("grPlot"))
self.verticalLayout.addWidget(self.grPlot)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
示例15: initUi
# 需要导入模块: import pyqtgraph [as 别名]
# 或者: from pyqtgraph import PlotWidget [as 别名]
def initUi(self):
"""初始化界面"""
self.setWindowTitle(u'K线工具')
# 主图
self.pw = pg.PlotWidget()
# 界面布局
self.lay_KL = pg.GraphicsLayout(border=(100,100,100))
self.lay_KL.setContentsMargins(10, 10, 10, 10)
self.lay_KL.setSpacing(0)
self.lay_KL.setBorder(color=(255, 0, 0, 255), width=0.8)
self.lay_KL.setZValue(0)
self.KLtitle = self.lay_KL.addLabel(u'')
self.pw.setCentralItem(self.lay_KL)
# 设置横坐标
xdict = {}
self.axisTime = MyStringAxis(xdict, orientation='bottom')
# 初始化子图
self.initplotKline()
self.initplotVol()
self.initplotOI()
# 注册十字光标
self.crosshair = Crosshair(self.pw,self)
# 设置界面
self.vb = QVBoxLayout()
self.vb.addWidget(self.pw)
self.setLayout(self.vb)
# 初始化完成
self.initCompleted = True
#----------------------------------------------------------------------