From 355b38dcc11e454b87ed5c54daa3ea8ac98332c2 Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Fri, 31 Jan 2014 21:26:01 -0500 Subject: [PATCH 1/4] Typo --- pyqtgraph/graphicsItems/AxisItem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index 429ff49c..2a5380ec 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -692,7 +692,7 @@ class AxisItem(GraphicsWidget): ## determine mapping between tick values and local coordinates dif = self.range[1] - self.range[0] if dif == 0: - xscale = 1 + xScale = 1 offset = 0 else: if axis == 0: From 13aa00d915bab1b024cbcce201d0a4bc6ac3049d Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Fri, 31 Jan 2014 22:10:17 -0500 Subject: [PATCH 2/4] Check that textRects is not empty, otherwise np.max raises ValueError. --- pyqtgraph/graphicsItems/AxisItem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py index 2a5380ec..a8509db3 100644 --- a/pyqtgraph/graphicsItems/AxisItem.py +++ b/pyqtgraph/graphicsItems/AxisItem.py @@ -810,10 +810,10 @@ class AxisItem(GraphicsWidget): ## measure all text, make sure there's enough room if axis == 0: textSize = np.sum([r.height() for r in textRects]) - textSize2 = np.max([r.width() for r in textRects]) + textSize2 = np.max([r.width() for r in textRects]) if textRects else 0 else: textSize = np.sum([r.width() for r in textRects]) - textSize2 = np.max([r.height() for r in textRects]) + textSize2 = np.max([r.height() for r in textRects]) if textRects else 0 ## If the strings are too crowded, stop drawing text now. ## We use three different crowding limits based on the number From fe11e6c1439bc21ae367afab154a388af7aee07e Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Fri, 31 Jan 2014 22:29:20 -0500 Subject: [PATCH 3/4] use examples directory for the output --- examples/SimplePlot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/SimplePlot.py b/examples/SimplePlot.py index f572743a..b4dba1ff 100644 --- a/examples/SimplePlot.py +++ b/examples/SimplePlot.py @@ -1,5 +1,6 @@ import initExample ## Add path to library (just for examples; you do not need this) +from os.path import * from pyqtgraph.Qt import QtGui, QtCore import pyqtgraph as pg import numpy as np @@ -7,7 +8,7 @@ plt = pg.plot(np.random.normal(size=100), title="Simplest possible plotting exam plt.getAxis('bottom').setTicks([[(x*20, str(x*20)) for x in range(6)]]) ## Start Qt event loop unless running in interactive mode or using pyside. ex = pg.exporters.SVGExporter.SVGExporter(plt.plotItem.scene()) -ex.export('/home/luke/tmp/test.svg') +ex.export(join(dirname(__file__), 'test.svg')) if __name__ == '__main__': import sys From 95bddca0147ffea2428fb4de6d88e6a8c6c5ddb9 Mon Sep 17 00:00:00 2001 From: Mikhail Terekhov Date: Fri, 31 Jan 2014 23:00:18 -0500 Subject: [PATCH 4/4] In ArrowItem allow individual parameter change through setStyle call. --- examples/Arrow.py | 3 ++- pyqtgraph/graphicsItems/ArrowItem.py | 9 ++++++--- pyqtgraph/graphicsItems/CurvePoint.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/Arrow.py b/examples/Arrow.py index 2cbff113..d5ea2a74 100644 --- a/examples/Arrow.py +++ b/examples/Arrow.py @@ -2,7 +2,7 @@ """ Display an animated arrowhead following a curve. This example uses the CurveArrow class, which is a combination -of ArrowItem and CurvePoint. +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. @@ -45,6 +45,7 @@ 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) +a.setStyle(headLen=40) p2.addItem(a) anim = a.makeAnimation(loop=-1) anim.start() diff --git a/pyqtgraph/graphicsItems/ArrowItem.py b/pyqtgraph/graphicsItems/ArrowItem.py index dcede02a..258f8b02 100644 --- a/pyqtgraph/graphicsItems/ArrowItem.py +++ b/pyqtgraph/graphicsItems/ArrowItem.py @@ -70,13 +70,16 @@ class ArrowItem(QtGui.QGraphicsPathItem): brush The brush used to fill the arrow. ================= ================================================= """ - self.opts = opts + try: + self.opts.update(opts) + except AttributeError: + self.opts = opts opt = dict([(k,self.opts[k]) for k in ['headLen', 'tipAngle', 'baseAngle', 'tailLen', 'tailWidth']]) self.path = fn.makeArrowPath(**opt) self.setPath(self.path) - if opts['pxMode']: + if self.opts['pxMode']: self.setFlags(self.flags() | self.ItemIgnoresTransformations) else: self.setFlags(self.flags() & ~self.ItemIgnoresTransformations) @@ -121,4 +124,4 @@ class ArrowItem(QtGui.QGraphicsPathItem): return pad - \ No newline at end of file + diff --git a/pyqtgraph/graphicsItems/CurvePoint.py b/pyqtgraph/graphicsItems/CurvePoint.py index 668830f7..d6fd2a08 100644 --- a/pyqtgraph/graphicsItems/CurvePoint.py +++ b/pyqtgraph/graphicsItems/CurvePoint.py @@ -112,6 +112,6 @@ class CurveArrow(CurvePoint): self.arrow = ArrowItem.ArrowItem(**opts) self.arrow.setParentItem(self) - def setStyle(**opts): + def setStyle(self, **opts): return self.arrow.setStyle(**opts)