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.

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

active_artist

Sets or returns the active artist.

Attributes Summary

selection_tools_layout

The selection tools layout.

selection_toolbar

The selection toolbar.

class_spinbox

The color class spinbox.

artists

Dictionary of artists.

selectors

Dictionary of selectors.

Methods Summary

add_artist(artist_type, artist_instance[, ...])

Adds a new artist instance to the artists dictionary.

add_selector(selector_type, selector_instance)

Adds a new selector instance to the selectors dictionary.

on_enable_selector(checked)

Enables or disables the selected selector.

Signals Summary

artist_changed_signal

Signal emitted when the current active_artist changes

Properties Documentation

active_artist#

Sets or returns the active artist.

If set, makes the selected artist visible and all other artists invisible.

Returns:

The active artist.

Return type:

Scatter or Histogram2D

Notes

artist_changed_signalSignal

Signal emitted when the current artist changes.

Attributes Documentation

selection_tools_layout: QHBoxLayout#

The selection tools layout.

selection_toolbar: CustomToolbarWidget#

The selection toolbar.

class_spinbox: QtColorSpinBox#

The color class spinbox.

artists: dict#

Dictionary of artists.

selectors: dict#

Dictionary of selectors.

Methods Documentation

add_artist(artist_type: ArtistType, artist_instance: Scatter | Histogram2D, visible: bool = False)#

Adds a new artist instance to the artists dictionary.

Parameters:
  • artist_type (ArtistType) – The type of the artist, defined by the ArtistType enum.

  • artist_instance (Scatter or Histogram2D) – An instance of the artist class.

add_selector(selector_type: SelectorType, selector_instance: InteractiveRectangleSelector | InteractiveEllipseSelector | InteractiveLassoSelector)#

Adds a new selector instance to the selectors dictionary.

Parameters:
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