Selectors#
- class biaplotter.selectors.Selector(ax: Axes | None = None, data: ndarray | None = None)#
Bases:
ABC
Abstract class for creating a selector.
- Parameters:
ax (plt.Axes, optional) – axes to which the selector will be applied.
data (np.ndarray) – data to be selected.
Properties Summary
Abstract property for the selector's data.
Attributes Summary
Stores the axes to which the selector will be applied.
Methods Summary
Abstract method to create a selector.
on_select
(vertices)Abstract method to select points based on the selector's shape.
remove
()Removes the selector from the canvas.
Properties Documentation
- data#
Abstract property for the selector’s data.
Attributes Documentation
- ax: Axes#
Stores the axes to which the selector will be applied.
Methods Documentation
- abstract create_selector()#
Abstract method to create a selector.
- abstract on_select(vertices: ndarray)#
Abstract method to select points based on the selector’s shape.
- remove()#
Removes the selector from the canvas.
- class biaplotter.selectors.BaseRectangleSelector(ax: Axes, data: ndarray | None = None)#
Bases:
Selector
Base class for creating a rectangle selector.
Inherits all parameters and attributes from Selector. For parameter and attribute details, see the Selector class documentation.
- Parameters:
ax (plt.Axes) – axes to which the selector will be applied.
data ((N, 2) np.ndarray) – data to be selected.
Properties Summary
Gets or sets the data from which points will be selected.
Attributes Summary
Stores the axes to which the selector will be applied.
The name of the selector, set to 'Rectangle Selector' by default.
Methods Summary
Creates a rectangle selector.
on_select
(eclick, erelease)Selects points within the rectangle and returns their indices.
remove
()Removes the selector from the canvas.
Properties Documentation
- data#
Gets or sets the data from which points will be selected.
Attributes Documentation
- ax: Axes#
Stores the axes to which the selector will be applied.
- name: str#
The name of the selector, set to ‘Rectangle Selector’ by default.
Methods Documentation
- create_selector()#
Creates a rectangle selector.
Useblit is set to True to improve performance. Left mouse button is used to draw the rectangle. Minimum span in x and y is set to 5 pixels. Span coordinates are set to pixels. Interactive is set to True to allow for interaction. Drag from anywhere is set to True to allow for drawing from any point.
- on_select(eclick, erelease) ndarray #
Selects points within the rectangle and returns their indices.
- Parameters:
eclick (MouseEvent) – The press event.
erelease (MouseEvent) – The release event.
- Returns:
The indices of the selected points.
- Return type:
np.ndarray
- remove()#
Removes the selector from the canvas.
- class biaplotter.selectors.BaseEllipseSelector(ax: Axes, data: ndarray | None = None)#
Bases:
Selector
Base class for creating an ellipse selector.
Inherits all parameters and attributes from Selector. For parameter and attribute details, see the Selector class documentation.
- Parameters:
ax (plt.Axes) – axes to which the selector will be applied.
data (np.ndarray) – data to be selected.
Properties Summary
Gets or sets the data from which points will be selected.
Attributes Summary
Stores the axes to which the selector will be applied.
The name of the selector, set to 'Ellipse Selector' by default.
Methods Summary
Creates an ellipse selector.
on_select
(eclick, erelease)Selects points within the ellipse and returns their indices.
remove
()Removes the selector from the canvas.
Properties Documentation
- data#
Gets or sets the data from which points will be selected.
Attributes Documentation
- ax: Axes#
Stores the axes to which the selector will be applied.
- name: str#
The name of the selector, set to ‘Ellipse Selector’ by default.
Methods Documentation
- create_selector()#
Creates an ellipse selector.
Useblit is set to True to improve performance. Left mouse button is used to draw the ellipse. Minimum span in x and y is set to 5 pixels. Span coordinates are set to pixels. Interactive is set to True to allow for interaction. Drag from anywhere is set to True to allow for drawing from any point.
- on_select(eclick, erelease)#
Selects points within the ellipse and returns their indices.
- Parameters:
eclick (MouseEvent) – The press event.
erelease (MouseEvent) – The release event.
- Returns:
The indices of the selected points.
- Return type:
np.ndarray
- remove()#
Removes the selector from the canvas.
- class biaplotter.selectors.BaseLassoSelector(ax: Axes, data: ndarray | None = None)#
Bases:
Selector
Base class for creating a lasso selector.
Inherits all parameters and attributes from Selector. For parameter and attribute details, see the Selector class documentation.
- Parameters:
ax (plt.Axes) – axes to which the selector will be applied.
data (np.ndarray) – data to be selected.
Properties Summary
Gets or sets the data from which points will be selected.
Attributes Summary
Stores the axes to which the selector will be applied.
The name of the selector, set to 'Lasso Selector' by default.
Methods Summary
Creates a lasso selector.
on_select
(vertices)Selects points within the lasso and returns their indices.
remove
()Removes the selector from the canvas.
Properties Documentation
- data#
Gets or sets the data from which points will be selected.
Attributes Documentation
- ax: Axes#
Stores the axes to which the selector will be applied.
- name: str#
The name of the selector, set to ‘Lasso Selector’ by default.
Methods Documentation
- create_selector()#
Creates a lasso selector.
Useblit is set to True to improve performance. Left mouse button is used to draw the lasso.
- on_select(vertices)#
Selects points within the lasso and returns their indices.
- Parameters:
vertices (np.ndarray) – The vertices of the lasso.
- Returns:
The indices of the selected points.
- Return type:
np.ndarray
- remove()#
Removes the selector from the canvas.
- class biaplotter.selectors.Interactive(ax: plt.Axes, canvas_widget: CanvasWidget, data: np.ndarray = None)#
Bases:
Selector
Interactive selector class.
Inherits all parameters and attributes from Selector. To be used as a base class together with a selector to turn selectors interactive.
- Parameters:
ax (plt.Axes) – axes to which the selector will be applied.
canvas_widget (CanvasWidget) – canvas widget to which the selector will be applied.
data ((N, 2) np.ndarray, optional) – data to be selected.
Notes
Slots:
update_class_value method intended to be connected by the color_spinbox_value_changed_signal emitted by the canvas_widget to have class_value synchronized.
update_data method intended to be connected by the data_changed_signal emitted by the active_artist to have the selector data synchronized.
update_active_artist method intended to be connected by the artist_changed_signal emitted by the canvas_widget to have the active_artist synchronized.
Signals and Slots:
This class automatically connects the following signals to slots:
color_spinbox_value_changed_signal emitted by the canvas_widget to update_class_value slot.
data_changed_signal emitted by the active_artist to update_data slot.
Properties Summary
Gets or sets the active artist.
Gets or sets the current class value.
Abstract property for the selector's data.
Gets or sets the indices of the selected points.
Attributes Summary
The canvas widget to which the selector will be applied.
Methods Summary
Applies the selection to the data, updating the colors.
Creates the selector and connects the button press event.
on_button_press
(event)Handles the button press event.
remove
()Removes the selector from the canvas and disconnects the button press event.
Slots Methods Summary
Update the active artist.
update_class_value
(value)Update the class value.
update_data
(value)Update the selector data.
Properties Documentation
- active_artist#
Gets or sets the active artist.
- class_value#
Gets or sets the current class value.
- data#
Abstract property for the selector’s data.
- selected_indices#
Gets or sets the indices of the selected points.
Attributes Documentation
- canvas_widget: CanvasWidget#
The canvas widget to which the selector will be applied.
Methods Documentation
- apply_selection()#
Applies the selection to the data, updating the colors.
- create_selector()#
Creates the selector and connects the button press event.
- on_button_press(event)#
Handles the button press event. Right-click applies the selection.
- Parameters:
event (MouseEvent) – The button press event.
- remove()#
Removes the selector from the canvas and disconnects the button press event.
Slots Methods Documentation
- update_active_artist()#
Update the active artist.
Notes
This slot is connected to the artist_changed_signal emitted by the canvas widget.
- update_class_value(value: int)#
Update the class value.
Notes
This slot is connected to the color_spinbox_value_changed_signal emitted by the canvas widget.
- update_data(value: ndarray)#
Update the selector data.
Notes
This slot is connected to the data_changed_signal emitted by the active artist.
- class biaplotter.selectors.InteractiveRectangleSelector(ax: plt.Axes, canvas_widget: CanvasWidget, data: np.ndarray = None)#
Bases:
Interactive
,BaseRectangleSelector
Interactive rectangle selector class.
Inherits all parameters and attributes from Interactive and BaseRectangleSelector. To be used as an interactive rectangle selector.
- Parameters:
ax (plt.Axes) – The axes to which the selector will be applied.
canvas_widget (biaplotter.plotter.CanvasWidget) – The canvas widget to which the selector will be applied.
data ((N, 2) np.ndarray, optional) – The data to be selected.
Attributes Summary
The name of the selector, set to 'Interactive Rectangle Selector' by default.
Methods Summary
on_select
(eclick, erelease)Selects points within the rectangle and assigns them to selected indices.
Attributes Documentation
- name: str#
The name of the selector, set to ‘Interactive Rectangle Selector’ by default.
Methods Documentation
- on_select(eclick, erelease)#
Selects points within the rectangle and assigns them to selected indices.
- Parameters:
eclick (MouseEvent) – The press event.
erelease (MouseEvent) – The release event.
- Returns:
The indices of the selected points.
- Return type:
np.ndarray
- class biaplotter.selectors.InteractiveEllipseSelector(ax: plt.Axes, canvas_widget: CanvasWidget, data: np.ndarray = None)#
Bases:
Interactive
,BaseEllipseSelector
Interactive ellipse selector class.
Inherits all parameters and attributes from Interactive and BaseEllipseSelector. To be used as an interactive ellipse selector.
- Parameters:
ax (plt.Axes) – The axes to which the selector will be applied.
canvas_widget (biaplotter.plotter.CanvasWidget) – The canvas widget to which the selector will be applied.
data ((N, 2) np.ndarray, optional) – The data to be selected.
Attributes Summary
The name of the selector, set to 'Interactive Ellipse Selector' by default.
Methods Summary
on_select
(eclick, erelease)Selects points within the ellipse and assigns them to selected indices.
Attributes Documentation
- name: str#
The name of the selector, set to ‘Interactive Ellipse Selector’ by default.
Methods Documentation
- on_select(eclick, erelease)#
Selects points within the ellipse and assigns them to selected indices.
- Parameters:
eclick (MouseEvent) – The press event.
erelease (MouseEvent) – The release event.
- Returns:
The indices of the selected points.
- Return type:
np.ndarray
- class biaplotter.selectors.InteractiveLassoSelector(ax: plt.Axes, canvas_widget: CanvasWidget, data: np.ndarray = None)#
Bases:
Interactive
,BaseLassoSelector
Interactive lasso selector class.
Inherits all parameters and attributes from Interactive and BaseLassoSelector. To be used as an interactive lasso selector.
- Parameters:
ax (plt.Axes) – The axes to which the selector will be applied.
canvas_widget (biaplotter.plotter.CanvasWidget) – The canvas widget to which the selector will be applied.
data ((N, 2) np.ndarray, optional) – The data to be selected.
name (str) – The name of the selector, set to ‘Interactive Lasso Selector’ by default.
Attributes Summary
The name of the selector, set to 'Interactive Lasso Selector' by default.
Methods Summary
on_select
(vertices)Selects points within the lasso and assigns them the current class value, updating colors.
Attributes Documentation
- name: str#
The name of the selector, set to ‘Interactive Lasso Selector’ by default.
Methods Documentation
- on_select(vertices: ndarray)#
Selects points within the lasso and assigns them the current class value, updating colors.
- Parameters:
vertices (np.ndarray) – The vertices of the lasso.
- Returns:
The indices of the selected points.
- Return type:
np.ndarray