Example updates
This commit is contained in:
parent
7401d3f3da
commit
fcf2c53c46
@ -1,7 +1,15 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
## Display an animated arrowhead following a curve.
|
||||||
|
## This example uses the CurveArrow class, which is a combination
|
||||||
|
## of ArrowItem and CurvePoint.
|
||||||
|
##
|
||||||
|
## To place a static arrow anywhere in a scene, use ArrowItem.
|
||||||
|
## To attach other types of item to a curve, use CurvePoint.
|
||||||
|
|
||||||
|
|
||||||
## Add path to library (just for examples; you do not need this)
|
## Add path to library (just for examples; you do not need this)
|
||||||
import sys, os
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from pyqtgraph.Qt import QtGui, QtCore
|
from pyqtgraph.Qt import QtGui, QtCore
|
||||||
@ -23,6 +31,6 @@ mw.show()
|
|||||||
anim = a.makeAnimation(loop=-1)
|
anim = a.makeAnimation(loop=-1)
|
||||||
anim.start()
|
anim.start()
|
||||||
|
|
||||||
## Start Qt event loop unless running in interactive mode.
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
if sys.flags.interactive != 1:
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
## Add path to library (just for examples; you do not need this)
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
import sys, os
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
||||||
|
|
||||||
|
|
||||||
from pyqtgraph.Qt import QtGui, QtCore
|
from pyqtgraph.Qt import QtGui, QtCore
|
||||||
import numpy as np
|
import numpy as np
|
||||||
@ -17,6 +14,7 @@ data = np.random.normal(size=(500,500))
|
|||||||
pg.show(data, title="Simplest possible image example")
|
pg.show(data, title="Simplest possible image example")
|
||||||
|
|
||||||
|
|
||||||
## Start Qt event loop unless running in interactive mode.
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
if sys.flags.interactive != 1:
|
import sys
|
||||||
|
if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
## Add path to library (just for examples; you do not need this)
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
import sys, os
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
||||||
|
|
||||||
|
|
||||||
from pyqtgraph.Qt import QtCore, QtGui
|
from pyqtgraph.Qt import QtCore, QtGui
|
||||||
@ -39,6 +37,6 @@ kern = np.array([
|
|||||||
img.setDrawKernel(kern, mask=kern, center=(1,1), mode='add')
|
img.setDrawKernel(kern, mask=kern, center=(1,1), mode='add')
|
||||||
img.setLevels([0, 10])
|
img.setLevels([0, 10])
|
||||||
|
|
||||||
## Start Qt event loop unless running in interactive mode.
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
if sys.flags.interactive != 1:
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
@ -11,11 +11,8 @@ import pyqtgraph.ptime as ptime
|
|||||||
app = QtGui.QApplication([])
|
app = QtGui.QApplication([])
|
||||||
|
|
||||||
## Create window with GraphicsView widget
|
## Create window with GraphicsView widget
|
||||||
win = QtGui.QMainWindow()
|
|
||||||
win.resize(800,800)
|
|
||||||
view = pg.GraphicsView()
|
view = pg.GraphicsView()
|
||||||
win.setCentralWidget(view)
|
view.show() ## show view alone in its own window
|
||||||
win.show()
|
|
||||||
|
|
||||||
## Allow mouse scale/pan. Normally we use a ViewBox for this, but
|
## Allow mouse scale/pan. Normally we use a ViewBox for this, but
|
||||||
## for simple examples this is easier.
|
## for simple examples this is easier.
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
## Add path to library (just for examples; you do not need this)
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
import sys, os
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
|
||||||
|
|
||||||
|
|
||||||
from pyqtgraph.Qt import QtGui, QtCore
|
from pyqtgraph.Qt import QtGui, QtCore
|
||||||
@ -82,6 +79,9 @@ line = pg.InfiniteLine(angle=90, movable=True)
|
|||||||
pw3.addItem(line)
|
pw3.addItem(line)
|
||||||
line.setBounds([0,200])
|
line.setBounds([0,200])
|
||||||
|
|
||||||
## Start Qt event loop unless running in interactive mode.
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
if sys.flags.interactive != 1:
|
|
||||||
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
|
import sys
|
||||||
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
## Add path to library (just for examples; you do not need this)
|
|
||||||
import sys, os
|
## This example demonstrates many of the 2D plotting capabilities
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
## in pyqtgraph. All of the plots may be panned/scaled by dragging with
|
||||||
|
## the left/right mouse buttons. Right click on any plot to show a context menu.
|
||||||
|
|
||||||
|
|
||||||
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
|
|
||||||
|
|
||||||
from pyqtgraph.Qt import QtGui, QtCore
|
from pyqtgraph.Qt import QtGui, QtCore
|
||||||
@ -82,6 +85,8 @@ def update():
|
|||||||
lr.sigRegionChanged.connect(update)
|
lr.sigRegionChanged.connect(update)
|
||||||
update()
|
update()
|
||||||
|
|
||||||
## Start Qt event loop unless running in interactive mode.
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
if sys.flags.interactive != 1:
|
import sys
|
||||||
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
|
||||||
|
3
examples/initExample.py
Normal file
3
examples/initExample.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
## make this version of pyqtgraph importable before any others
|
||||||
|
import sys, os
|
||||||
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
11
examples/template.py
Normal file
11
examples/template.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
|
|
||||||
|
import pyqtgraph as pg
|
||||||
|
from pyqtgraph.Qt import QtCore, QtGui
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
|
import sys
|
||||||
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
|
QtGui.QApplication.instance().exec_()
|
25
examples/text.py
Normal file
25
examples/text.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
## This example shows how to insert text into a scene using QTextItem
|
||||||
|
|
||||||
|
|
||||||
|
import initExample ## Add path to library (just for examples; you do not need this)
|
||||||
|
|
||||||
|
import pyqtgraph as pg
|
||||||
|
from pyqtgraph.Qt import QtCore, QtGui
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
x = np.linspace(-100, 100, 1000)
|
||||||
|
y = np.sin(x) / x
|
||||||
|
plot = pg.plot(x, y)
|
||||||
|
|
||||||
|
## Create text object, use HTML tags to specify color (default is black; won't be visible)
|
||||||
|
text = pg.TextItem(html='<div style="text-align: center"><span style="color: #FFF;">This is the</span><br><span style="color: #FF0;">PEAK</span></div>')
|
||||||
|
plot.addItem(text)
|
||||||
|
text.setPos(0, y.max())
|
||||||
|
|
||||||
|
|
||||||
|
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||||
|
import sys
|
||||||
|
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
|
||||||
|
QtGui.QApplication.instance().exec_()
|
Loading…
Reference in New Issue
Block a user