5. OutlierRejection#

class OutlierRejection(ax: Axes, data: ndarray, plot_type: str = 'scatter', bins: int = 20, marker: str = '.', label: str = '')#

Bases: object

WORK IN PROGRESS

Handles the selection and removal of the outliers points from the plots.

Allows the users to select a set of points using the lasso selector and remove them.

Attributes

ax

Axes object of the plot.

canvas

Canvas attribute of the plot.

data

Data array for scatter or histogram.

label

Label for the plot.

lasso

Lasso object to handle the mouse events.

marker

Marker of the plot.

removed_indices

List to save the indices of the outlier points

scatter

Scatter plot object.

Methods

apply_lasso(ax, data, plot_type, label[, ...])

Applies the lasso selector to a single plot and returns the removed indices.

onselect(coords)

Handles selection of histogram bins or scatter points for removal using lasso.

set_outliers(json_file_path)

Updates the outlier flag in a JSON file for specified indices.

update_plot()

Updates scatter plot by removing selected points.

static apply_lasso(ax: Axes, data: array, plot_type: str, label: str, marker: str = 'o', bins: int = 20)#

Applies the lasso selector to a single plot and returns the removed indices.

Parameters:
  • ax (Axes) – Matplotlib Axes object.

  • data (np.array) – Data array for scatter or histogram.

  • plot_type (str) – Type of plot (“scatter” or “histogram”).

  • label (str) – Label for the dataset.

  • marker (str, optional) – Marker style for scatter plots (ignored for histograms).

  • bins (int, optional) – Number of bins for histogram (ignored for scatter plots).

onselect(coords: list)#

Handles selection of histogram bins or scatter points for removal using lasso.

Parameters:

coords (list[tuple[float, float]]) – List of (x, y) coordinates selected by the lasso tool.

set_outliers(json_file_path)#

Updates the outlier flag in a JSON file for specified indices.

Parameters:
  • outlier_indices (list[int]) – List of indices marked as outliers.

  • json_file_path (str) – Path to the JSON file containing measurement data.

update_plot()#

Updates scatter plot by removing selected points.

property ax#

Axes object of the plot. :base: OutlierRejection :type: matplotlib.axes.Axes

property canvas#

Canvas attribute of the plot.

Base:

OutlierRejection

Type:

FigureCanvasBase

property data#

Data array for scatter or histogram.

Base:

OutlierRejection

Base:

numpy.ndarray

property label#

Label for the plot.

Base:

OutlierRejection

Type:

str

property lasso#

Lasso object to handle the mouse events.

Base:

OutlierRejection

Type:

LassoSelector

property marker#

Marker of the plot.

Base:

OutlierRejection

Type:

str

property removed_indices#

List to save the indices of the outlier points

Base:

OutlierRejection

Type:

list[int]

property scatter#

Scatter plot object.

Base:

OutlierRejection

Type:

PathCollection