Commit fcf2c53c authored by Luke Campagnola's avatar Luke Campagnola
Browse files

Example updates

parent 7401d3f3
# -*- 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)
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
import initExample ## Add path to library (just for examples; you do not need this)
import numpy as np
from pyqtgraph.Qt import QtGui, QtCore
......@@ -23,6 +31,6 @@ mw.show()
anim = a.makeAnimation(loop=-1)
anim.start()
## Start Qt event loop unless running in interactive mode.
if sys.flags.interactive != 1:
## Start Qt event loop unless running in interactive mode or using pyside.
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
app.exec_()
## 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__), '..', '..'))
import initExample ## Add path to library (just for examples; you do not need this)
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
......@@ -17,6 +14,7 @@ data = np.random.normal(size=(500,500))
pg.show(data, title="Simplest possible image example")
## Start Qt event loop unless running in interactive mode.
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_()
# -*- coding: utf-8 -*-
## 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__), '..', '..'))
import initExample ## Add path to library (just for examples; you do not need this)
from pyqtgraph.Qt import QtCore, QtGui
......@@ -39,6 +37,6 @@ kern = np.array([
img.setDrawKernel(kern, mask=kern, center=(1,1), mode='add')
img.setLevels([0, 10])
## Start Qt event loop unless running in interactive mode.
if sys.flags.interactive != 1:
## Start Qt event loop unless running in interactive mode or using pyside.
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
app.exec_()
......@@ -11,11 +11,8 @@ import pyqtgraph.ptime as ptime
app = QtGui.QApplication([])
## Create window with GraphicsView widget
win = QtGui.QMainWindow()
win.resize(800,800)
view = pg.GraphicsView()
win.setCentralWidget(view)
win.show()
view.show() ## show view alone in its own window
## Allow mouse scale/pan. Normally we use a ViewBox for this, but
## for simple examples this is easier.
......
#!/usr/bin/python
# -*- coding: utf-8 -*-
## 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__), '..', '..'))
import initExample ## Add path to library (just for examples; you do not need this)
from pyqtgraph.Qt import QtGui, QtCore
......@@ -82,6 +79,9 @@ line = pg.InfiniteLine(angle=90, movable=True)
pw3.addItem(line)
line.setBounds([0,200])
## Start Qt event loop unless running in interactive mode.
if sys.flags.interactive != 1:
import initExample ## Add path to library (just for examples; you do not need this)
## 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_()
#!/usr/bin/python
# -*- coding: utf-8 -*-
## 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__), '..', '..'))
## This example demonstrates many of the 2D plotting capabilities
## 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
......@@ -82,6 +85,8 @@ def update():
lr.sigRegionChanged.connect(update)
update()
## Start Qt event loop unless running in interactive mode.
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_()
## make this version of pyqtgraph importable before any others
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
# -*- 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_()
# -*- 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_()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment