From 170592c29431f9d9660e2f193adf98242c054fae Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Sun, 21 Feb 2016 23:28:24 -0800 Subject: [PATCH] update example --- examples/plottingItems.py | 13 +++++++------ pyqtgraph/graphicsItems/InfiniteLine.py | 2 ++ pyqtgraph/graphicsItems/TextItem.py | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/plottingItems.py b/examples/plottingItems.py index a7926826..d90d81ab 100644 --- a/examples/plottingItems.py +++ b/examples/plottingItems.py @@ -16,12 +16,13 @@ win.resize(1000,600) # Enable antialiasing for prettier plots pg.setConfigOptions(antialias=True) -p1 = win.addPlot(title="Plot Items example", y=np.random.normal(size=100)) +p1 = win.addPlot(title="Plot Items example", y=np.random.normal(size=100, scale=10), pen=0.5) +p1.setYRange(-40, 40) inf1 = pg.InfiniteLine(movable=True, angle=90, text='x={value:0.2f}', - textOpts={'position':0.2, 'color': (200,200,100), 'fill': (200,200,200,50)}) -inf2 = pg.InfiniteLine(movable=True, angle=0, pen=(0, 0, 200), bounds = [-2, 2], hoverPen=(0,200,0), text='y={value:0.2f}mm', - textOpts={'color': (200,0,0), 'movable': True, 'fill': 0.5}) -inf3 = pg.InfiniteLine(movable=True, angle=45, text='diagonal', textOpts={'rotateAxis': [1, 0]}) + textOpts={'position':0.1, 'color': (200,200,100), 'fill': (200,200,200,50), 'movable': True}) +inf2 = pg.InfiniteLine(movable=True, angle=0, pen=(0, 0, 200), bounds = [-20, 20], hoverPen=(0,200,0), text='y={value:0.2f}mm', + textOpts={'color': (200,0,0), 'movable': True, 'fill': (0, 0, 200, 100)}) +inf3 = pg.InfiniteLine(movable=True, angle=45, pen='g', text='diagonal', textOpts={'rotateAxis': [1, 0], 'fill': (0, 200, 0, 100), 'movable': True}) inf1.setPos([2,2]) #inf1.setTextLocation(position=0.75) #inf2.setTextLocation(shift=0.8) @@ -29,7 +30,7 @@ p1.addItem(inf1) p1.addItem(inf2) p1.addItem(inf3) -lr = pg.LinearRegionItem(values=[5, 10]) +lr = pg.LinearRegionItem(values=[70, 80]) p1.addItem(lr) ## Start Qt event loop unless running in interactive mode or using pyside. diff --git a/pyqtgraph/graphicsItems/InfiniteLine.py b/pyqtgraph/graphicsItems/InfiniteLine.py index 2a72f848..de7f99f6 100644 --- a/pyqtgraph/graphicsItems/InfiniteLine.py +++ b/pyqtgraph/graphicsItems/InfiniteLine.py @@ -323,6 +323,8 @@ class InfLineLabel(TextItem): self.updatePosition() def updatePosition(self): + # update text position to relative view location along line + view = self.getViewBox() if not self.isVisible() or not isinstance(view, ViewBox): # not in a viewbox, skip update diff --git a/pyqtgraph/graphicsItems/TextItem.py b/pyqtgraph/graphicsItems/TextItem.py index 657e425b..220d5859 100644 --- a/pyqtgraph/graphicsItems/TextItem.py +++ b/pyqtgraph/graphicsItems/TextItem.py @@ -10,7 +10,7 @@ class TextItem(GraphicsObject): GraphicsItem displaying unscaled text (the text will always appear normal even inside a scaled ViewBox). """ def __init__(self, text='', color=(200,200,200), html=None, anchor=(0,0), - border=None, fill=None, angle=0, rotateAxis=None): + border=None, fill=None, angle=0, rotateAxis=(1, 0)): """ ============== ================================================================================= **Arguments:**