Plotter#
- class biaplotter.plotter.CanvasWidget(napari_viewer: napari.viewer.Viewer, parent: QWidget | None = None, label_text: str = 'Class:')#
Bases:
BaseNapariMPLWidget
A widget that contains a canvas with matplotlib axes and a selection toolbar.
The widget includes a selection toolbar with buttons to enable/disable selection tools. The selection toolbar includes a color class spinbox to select the class to assign to selections. The widget includes artists and selectors to plot data and select points.
- Parameters:
napari_viewer (napari.viewer.Viewer) – The napari viewer.
parent (QWidget, optional) – The parent widget, by default None.
label_text (str, optional) – The text to display next to the class spinbox, by default “Class:”.
Notes
Signals:
artist_changed_signal emitted when the current artist changes.
selector_changed_signal emitted when the current selector changes.
show_color_overlay_signal emitted when the plot overlay is shown or hidden.
Signals and Slots:
This class automatically connects the following signals to slots:
data_changed_signal from each artist to the update_data slot in each selector. This allows artists to notify selectors when the data changes. Selectors can then synchronize their data with the artist’s data.
Properties Summary
Gets or sets the active artist.
Gets or sets the active selector.
Gets or sets the visibility of the plot overlay.
Methods Summary
add_artist
(artist_name, artist_instance[, ...])Adds a new artist instance to the artists dictionary using a string name.
remove_artist
(artist_name)Removes an artist from the instance, including from the dictionary.
add_selector
(selector_name, selector_instance)Adds a new selector instance to the selectors dictionary using a string name.
remove_selector
(selector_name)Removes a selector from the instance, including from the dictionary.
on_enable_selector
(checked)Enables or disables the selected selector.
Signals Summary
Signal emitted when the current active_artist changes
Signal emitted when the current active_selector changes
Signal emitted when the plot overlay is shown or hidden
Properties Documentation
- active_artist#
Gets or sets the active artist.
If set, makes the selected artist visible and all other artists invisible.
- Returns:
The active artist.
- Return type:
- active_selector#
Gets or sets the active selector.
- Returns:
The active selector.
- Return type:
InteractiveRectangleSelector or InteractiveEllipseSelector or InteractiveLassoSelector
- show_color_overlay#
Gets or sets the visibility of the plot overlay.
- Returns:
True if the overlay is visible, False otherwise.
- Return type:
bool
Methods Documentation
- add_artist(artist_name: str, artist_instance: Scatter | Histogram2D, visible: bool = False)#
Adds a new artist instance to the artists dictionary using a string name.
- Parameters:
artist_name (str) – The name of the artist (e.g., “scatter”, “SCATTER”, “Scatter”).
artist_instance (Scatter or Histogram2D) – An instance of the artist class.
visible (bool, optional) – Whether the artist should be visible initially, by default False.
- remove_artist(artist_name: str)#
Removes an artist from the instance, including from the dictionary.
- Parameters:
artist_name (str) – The name of the artist to remove.
- add_selector(selector_name: str, selector_instance)#
Adds a new selector instance to the selectors dictionary using a string name.
- Parameters:
selector_name (str) – The name of the selector (e.g., “lasso”, “LASSO”, “Lasso”).
selector_instance (InteractiveRectangleSelector or InteractiveEllipseSelector or InteractiveLassoSelector) – An instance of the selector class.
- remove_selector(selector_name: str)#
Removes a selector from the instance, including from the dictionary.
- Parameters:
selector_name (str) – The name of the selector to remove.
- on_enable_selector(checked: bool)#
Enables or disables the selected selector.
Enabling a selector disables all other selectors.
- Parameters:
checked (bool) – Whether the button is checked or not.
Signals Documentation
- artist_changed_signal: Signal#
Signal emitted when the current active_artist changes
- selector_changed_signal: Signal#
Signal emitted when the current active_selector changes
- show_color_overlay_signal: Signal#
Signal emitted when the plot overlay is shown or hidden