class pyqtgraph.InfiniteLine(pos=None, angle=90, pen=None, movable=False, bounds=None, hoverPen=None, label=None, labelOpts=None, span=(0, 1), markers=None, name=None)[source]

Bases: GraphicsObject

Displays a line of infinite length. This line may be dragged to indicate a position in data coordinates.





sigClicked(self, ev)

__init__(pos=None, angle=90, pen=None, movable=False, bounds=None, hoverPen=None, label=None, labelOpts=None, span=(0, 1), markers=None, name=None)[source]



Position of the line. This can be a QPointF or a single value for vertical/horizontal lines.


Angle of line in degrees. 0 is horizontal, 90 is vertical.


Pen to use when drawing line. Can be any arguments that are valid for mkPen. Default pen is transparent yellow.


Pen to use when the mouse cursor hovers over the line. Only used when movable=True.


If True, the line can be dragged to a new position by the user.


Optional [min, max] bounding values. Bounds are only valid if the line is vertical or horizontal.


Pen to use when drawing line when hovering over it. Can be any arguments that are valid for mkPen. Default pen is red.


Text to be displayed in a label attached to the line, or None to show no label (default is None). May optionally include formatting strings to display the line value.


A dict of keyword arguments to use when constructing the text label. See InfLineLabel.


Optional tuple (min, max) giving the range over the view to draw the line. For example, with a vertical line, use span=(0.5, 1) to draw only on the top half of the view.


List of (marker, position, size) tuples, one per marker to display on the line. See the addMarker method.


Name of the item

addMarker(marker, position=0.5, size=10.0)[source]

Add a marker to be displayed on the line.



String indicating the style of marker to add: '<|', '|>', '>|', '|<', '<|>', '>|<', '^', 'v', 'o'


Position (0.0-1.0) along the visible extent of the line to place the marker. Default is 0.5.


Size of the marker in pixels. Default is 10.0.


Return the (minimum, maximum) values allowed when dragging.


Remove all markers from this line.


Takes angle argument in degrees. 0 is horizontal; 90 is vertical.

Note that the use of value() and setValue() changes if the line is not vertical or horizontal.


Set the (minimum, maximum) allowable values when dragging.

setHoverPen(*args, **kwargs)[source]

Set the pen for drawing the line while the mouse hovers over it. Allowable arguments are any that are valid for mkPen.

If the line is not movable, then hovering is also disabled.

Added in version 0.9.9.


Set whether the line is movable by the user.

setPen(*args, **kwargs)[source]

Set the pen for drawing the line. Allowable arguments are any that are valid for mkPen.


Set the position of the line. If line is horizontal or vertical, v can be a single value. Otherwise, a 2D coordinate must be specified (list, tuple and QPointF are all acceptable).


Return the value of the line. Will be a single number for horizontal and vertical lines, and a list of [x,y] values for diagonal lines.


Called whenever the transformation matrix of the view has changed. (eg, the view range has changed or the view was resized)

class pyqtgraph.InfLineLabel(line, text='', movable=False, position=0.5, anchors=None, **kwds)[source]

A TextItem that attaches itself to an InfiniteLine.

This class extends TextItem with the following features:

  • Automatically positions adjacent to the line at a fixed position along the line and within the view box.

  • Automatically reformats text when the line value has changed.

  • Can optionally be dragged to change its location along the line.

  • Optionally aligns to its parent line.



The InfiniteLine to which this label will be attached.


String to display in the label. May contain a {value} formatting string to display the current value of the line.


Bool; if True, then the label can be dragged along the line.


Relative position (0.0-1.0) within the view to position the label along the line.


List of (x,y) pairs giving the text anchor positions that should be used when the line is moved to one side of the view or the other. This allows text to switch to the opposite side of the line as it approaches the edge of the view. These are automatically selected for some common cases, but may be specified if the default values give unexpected results.

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.

__init__(line, text='', movable=False, position=0.5, anchors=None, **kwds)[source]

Set the text format string for this label.

May optionally contain “{value}” to include the lines current value (the text will be reformatted whenever the line is moved).


Set whether this label is movable by dragging along the line.


Set the relative position (0.0-1.0) of this label within the view box and along the line.

For horizontal (angle=0) and vertical (angle=90) lines, a value of 0.0 places the text at the bottom or left of the view, respectively.