Skip to main content
`Ctrl`+`K`

# LinearRegionItem

class pyqtgraph.LinearRegionItem(

  values=(0, 1),
  orientation='vertical',
  brush=None,
  pen=None,
  hoverBrush=None,
  hoverPen=None,
  movable=True,
  bounds=None,
  span=(0, 1),
  swapMode='sort',
  clipItem=None,

)

  Bases: `GraphicsObject`

  Used for marking a horizontal or vertical region in plots. The region can be dragged and is bounded by lines which can be dragged individually.

  Signals: |
  sigRegionChangeFinished(self) | Emitted when the user has finished dragging the region (or one of its lines) and when the region is changed programatically.
  sigRegionChanged(self) | Emitted while the user is dragging the region (or one of its lines) and when the region is changed programatically.

  __init__(
    values=(0, 1),
    orientation='vertical',
    brush=None,
    pen=None,
    hoverBrush=None,
    hoverPen=None,
    movable=True,
    bounds=None,
    span=(0, 1),
    swapMode='sort',
    clipItem=None,
  )

    Create a new LinearRegionItem.

    Arguments: |
    values | A list of the positions of the lines in the region. These are not limits; limits can be set by specifying bounds.
    orientation | Options are ‘vertical’ or ‘horizontal’ The default is ‘vertical’, indicating that the region is bounded by vertical lines.
    brush | Defines the brush that fills the region. Can be any arguments that are valid for `mkBrush`. Default is transparent blue.
    pen | The pen to use when drawing the lines that bound the region.
    hoverBrush | The brush to use when the mouse is hovering over the region.
    hoverPen | The pen to use when the mouse is hovering over the region.
    movable | If True, the region and individual lines are movable by the user; if False, they are static.
    bounds | Optional [min, max] bounding values for the region
    span | Optional [min, max] giving the range over the view to draw the region. For example, with a vertical line, use `span=(0.5, 1)` to draw only on the top half of the view.

    swapMode

    Sets the behavior of the region when the lines are moved such that their order reverses:

    > - “block” means the user cannot drag one line past the other

    > - “push” causes both lines to be moved if one would cross the other

    > - “sort” means that lines may trade places, but the output of getRegion always gives the line positions in ascending order.

    > - None means that no attempt is made to handle swapped line positions.

    The default is “sort”.

    clipItem | An item whose bounds will be used to limit the region bounds. This is useful when a LinearRegionItem is added on top of an `ImageItem` or `PlotDataItem` and the visual region should not extend beyond its range. This overrides `bounds`.

  getRegion()

    Return the values at the edges of the region.

  setBounds(
    bounds,
  )

    Set `(min, max)` bounding values for the region.

    The current position is only affected it is outside the new bounds. See `setRegion()` to set the position of the region.

    Use `(None, None)` to disable bounds.

  setBrush(
    *br,
    **kargs,
  )

    Set the brush that fills the region. Can have any arguments that are valid for `mkBrush`.

  setClipItem(
    item=None,
  )

    Set an item to which the region is bounded.

    If `None`, bounds are disabled.

  setHoverBrush(
    *br,
    **kargs,
  )

    Set the brush that fills the region when the mouse is hovering over. Can have any arguments that are valid for `mkBrush`.

  setMovable(
    m=True,
  )

    Set lines to be movable by the user, or not. If lines are movable, they will also accept HoverEvents.

  setRegion(
    rgn,
  )

    Set the values for the edges of the region.

    Arguments: |
    rgn | A list or tuple of the lower and upper values.