cleanup: docs, default args
This commit is contained in:
parent
e4bdc17112
commit
bd0e490821
@ -16,20 +16,27 @@ win.resize(1000,600)
|
||||
# Enable antialiasing for prettier plots
|
||||
pg.setConfigOptions(antialias=True)
|
||||
|
||||
# Create a plot with some random data
|
||||
p1 = win.addPlot(title="Plot Items example", y=np.random.normal(size=100, scale=10), pen=0.5)
|
||||
p1.setYRange(-40, 40)
|
||||
|
||||
# Add three infinite lines with labels
|
||||
inf1 = pg.InfiniteLine(movable=True, angle=90, label='x={value:0.2f}',
|
||||
labelOpts={'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), label='y={value:0.2f}mm',
|
||||
labelOpts={'color': (200,0,0), 'movable': True, 'fill': (0, 0, 200, 100)})
|
||||
inf3 = pg.InfiniteLine(movable=True, angle=45, pen='g', label='diagonal', labelOpts={'rotateAxis': [1, 0], 'fill': (0, 200, 0, 100), 'movable': True})
|
||||
inf3 = pg.InfiniteLine(movable=True, angle=45, pen='g', label='diagonal',
|
||||
labelOpts={'rotateAxis': [1, 0], 'fill': (0, 200, 0, 100), 'movable': True})
|
||||
inf1.setPos([2,2])
|
||||
p1.addItem(inf1)
|
||||
p1.addItem(inf2)
|
||||
p1.addItem(inf3)
|
||||
|
||||
# Add a linear region with a label
|
||||
lr = pg.LinearRegionItem(values=[70, 80])
|
||||
p1.addItem(lr)
|
||||
label = pg.InfLineLabel(lr.lines[1], "region 1", position=0.95, rotateAxis=(1,0), anchor=(1, 1))
|
||||
|
||||
|
||||
## Start Qt event loop unless running in interactive mode or using pyside.
|
||||
if __name__ == '__main__':
|
||||
|
@ -8,7 +8,7 @@ import numpy as np
|
||||
import weakref
|
||||
|
||||
|
||||
__all__ = ['InfiniteLine']
|
||||
__all__ = ['InfiniteLine', 'InfLineLabel']
|
||||
|
||||
|
||||
class InfiniteLine(GraphicsObject):
|
||||
@ -310,7 +310,9 @@ class InfLineLabel(TextItem):
|
||||
along the line.
|
||||
=============== ==================================================================
|
||||
|
||||
All extra keyword arguments are passed to TextItem.
|
||||
All extra keyword arguments are passed to TextItem. A particularly useful
|
||||
option here is to use `rotateAxis=(1, 0)`, which will cause the text to
|
||||
be automatically rotated parallel to the line.
|
||||
"""
|
||||
def __init__(self, line, text="", movable=False, position=0.5, **kwds):
|
||||
self.line = line
|
||||
|
@ -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=(1, 0)):
|
||||
border=None, fill=None, angle=0, rotateAxis=None):
|
||||
"""
|
||||
============== =================================================================================
|
||||
**Arguments:**
|
||||
@ -30,6 +30,15 @@ class TextItem(GraphicsObject):
|
||||
Allows text to follow both the position and orientation of its parent while still
|
||||
discarding any scale and shear factors.
|
||||
============== =================================================================================
|
||||
|
||||
|
||||
The effects of the `rotateAxis` and `angle` arguments are added independently. So for example:
|
||||
|
||||
* rotateAxis=None, angle=0 -> normal horizontal text
|
||||
* rotateAxis=None, angle=90 -> normal vertical text
|
||||
* rotateAxis=(1, 0), angle=0 -> text aligned with x axis of its parent
|
||||
* rotateAxis=(0, 1), angle=0 -> text aligned with y axis of its parent
|
||||
* rotateAxis=(1, 0), angle=90 -> text orthogonal to x axis of its parent
|
||||
"""
|
||||
|
||||
self.anchor = Point(anchor)
|
||||
|
Loading…
Reference in New Issue
Block a user