bec_widgets.utils.plot_indicator_items#

Module to create an arrow item for a pyqtgraph plot

Classes#

BECArrowItem

Class to create an arrow item which can be added to a pyqtgraph plot.

BECIndicatorItem

BECTickItem

Class to create a tick item which can be added to a pyqtgraph plot.

Module Contents#

class BECArrowItem(plot_item: pyqtgraph.PlotItem = None, parent=None)#

Bases: BECIndicatorItem

Class to create an arrow item which can be added to a pyqtgraph plot. It can be either added directly to a view box or a plot item. To add the arrow item to a view box or plot item, use the add_to_plot method.

Parameters:
  • view_box (pg.ViewBox | pg.PlotItem) – The view box or plot item to which the arrow item should be added.

  • parent (QObject) – The parent object.

Signals:

position_changed (tuple[float, float]): Signal emitted when the position of the arrow item has changed. position_changed_str (tuple[str, str]): Signal emitted when the position of the arrow item has changed.

add_to_plot()#

Add the arrow item to the view box or plot item.

cleanup() None#

Cleanup the item

remove_from_plot()#

Remove the arrow item from the view box or plot item.

set_position(pos: tuple[float, float]) None#

Set the position of the arrow item

Parameters:

pos (tuple) – The position of the arrow item as a tuple (x, y).

set_style(style: dict) None#

Set the style of the arrow item

Parameters:

style (dict) – The style of the arrow item. Dictionary with key, value pairs which are accepted from the pg.ArrowItem.setStyle method.

arrow_item#
position_changed#
position_changed_str#
class BECIndicatorItem(plot_item: pyqtgraph.PlotItem = None, parent=None)#

Bases: qtpy.QtCore.QObject

abstractmethod add_to_plot() None#

Add the item to the plot

check_log()#

Checks if the x or y axis is in log scale and updates the internal state accordingly.

abstractmethod remove_from_plot() None#

Remove the item from the plot

abstractmethod set_position(pos) None#

This method should implement the logic to set the position of the item on the plot. Depending on the child class, the position can be a tuple (x,y) or a single value, i.e. x position where y position is fixed.

accent_colors#
is_log_x = False#
is_log_y = False#
property item_on_plot: bool#

Returns if the item is on the plot

plot_item = None#
class BECTickItem(plot_item: pyqtgraph.PlotItem = None, parent=None)#

Bases: BECIndicatorItem

Class to create a tick item which can be added to a pyqtgraph plot. The tick item will be added to the layout of the plot item and can be used to indicate a position

add_to_plot()#

Add the tick item to the view box or plot item.

cleanup() None#

Cleanup the item

remove_from_plot()#

Remove the tick item from the view box or plot item.

set_position(pos: float) None#

Set the x position of the tick item

Parameters:

pos (float) – The position of the tick item.

update_range(_, view_range: tuple[float, float]) None#

Update the range of the tick item

Parameters:
  • vb (pg.ViewBox) – The view box.

  • viewRange (tuple) – The view range.

update_tick_pos_y()#

Update tick position, while respecting the tick_item coordinates

position_changed#
position_changed_str#
tick = None#
tick_item#