From 55e58ac6ad02f5fcb34ce3498cd64e0b058f0a34 Mon Sep 17 00:00:00 2001 From: Luke Campagnola <> Date: Tue, 29 May 2012 23:44:14 -0400 Subject: [PATCH] updated arrow example --- examples/Arrow.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/examples/Arrow.py b/examples/Arrow.py index ae118507..4a8b8e13 100644 --- a/examples/Arrow.py +++ b/examples/Arrow.py @@ -15,17 +15,35 @@ import pyqtgraph as pg app = QtGui.QApplication([]) -mw = QtGui.QMainWindow() -mw.resize(300,300) -p = pg.PlotWidget() -mw.setCentralWidget(p) -c = p.plot(x=np.sin(np.linspace(0, 2*np.pi, 1000)), y=np.cos(np.linspace(0, 6*np.pi, 1000))) +w = QtGui.QMainWindow() +cw = pg.GraphicsLayoutWidget() +w.show() +w.resize(400,600) +w.setCentralWidget(cw) + +p = cw.addPlot(row=0, col=0) +p2 = cw.addPlot(row=1, col=0) + +## variety of arrow shapes +a1 = pg.ArrowItem(angle=-160, tipAngle=60, headLen=40, tailLen=40, tailWidth=20, pen={'color': 'w', 'width': 3}) +a2 = pg.ArrowItem(angle=-120, tipAngle=30, baseAngle=20, headLen=40, tailLen=40, tailWidth=8, pen=None, brush='y') +a3 = pg.ArrowItem(angle=-60, tipAngle=30, baseAngle=20, headLen=40, tailLen=None, brush=None) +a4 = pg.ArrowItem(angle=-20, tipAngle=30, baseAngle=-30, headLen=40, tailLen=None) +a2.setPos(10,0) +a3.setPos(20,0) +a4.setPos(30,0) +p.addItem(a1) +p.addItem(a2) +p.addItem(a3) +p.addItem(a4) +p.setRange(QtCore.QRectF(-20, -10, 60, 20)) + + +## Animated arrow following curve +c = p2.plot(x=np.sin(np.linspace(0, 2*np.pi, 1000)), y=np.cos(np.linspace(0, 6*np.pi, 1000))) a = pg.CurveArrow(c) -p.addItem(a) - -mw.show() - +p2.addItem(a) anim = a.makeAnimation(loop=-1) anim.start()