spacr.qt.widgets.grouped_plot

Render data-backed grouped comparisons with interchangeable graph types.

A PlotSpec retains the source frame, group and value columns, observation unit, and selected graph type. Retaining these data allows the widget to redraw compatible graph types and export the figure together with its source rows and statistical comparison.

Classes

GroupedPlot

A pyqtgraph plot of a PlotSpec, redrawable as any kind.

PlotSpec

Data and display metadata required to render a grouped plot.

Module Contents

class spacr.qt.widgets.grouped_plot.GroupedPlot(spec: PlotSpec | None = None, parent=None, **kwargs)[source]

Bases: spacr.qt.widgets.fast_plots.FastPlot

A pyqtgraph plot of a PlotSpec, redrawable as any kind.

Variables:

spec – what is drawn. Assign through show_spec().

Parameters:
  • spec – what to draw. None builds an empty plot; assign later through show_spec() rather than by setting spec.

  • parent – parent widget.

Create the grouped plot, optionally drawing a spec straight away.

Parameters:
  • spec – the plot to draw; None leaves the plot empty.

  • parent – parent widget, or None.

  • kwargs – passed through to the base plot.

comparison_groups() dict | None[source]

Return grouped values for export-time statistical comparison.

Returns None unless the retained specification contains at least two groups.

comparison_unit() str[source]

What one point on this plot IS – a well, a field, an object.

NAMED RATHER THAN ASSUMED, because it decides what a comparison means: the same data compared per well and per object gives different p-values, and only one of them answers the question asked.

Returns:

the unit’s name, observation when unspecified.

export_settings() dict[source]

The parent’s export settings, plus this plot’s grouping.

Returns:

the settings dict.

frame()[source]

Return the source rows exported to data.csv.

show_as(kind: str) int[source]

Redraw the retained data using graph type kind.

Raises:

ValueError – for a kind this data cannot support. Drawing it would otherwise imply a relationship unsupported by the available data shape.

show_spec(spec: PlotSpec) int[source]

Draw spec. Returns the number of groups drawn.

class spacr.qt.widgets.grouped_plot.PlotSpec[source]

Data and display metadata required to render a grouped plot.

The retained frame supports graph-type compatibility checks, redrawing, data export, and statistical comparison without reconstructing the plot from rendered graphics.

default_kind() str[source]

What this data is born as, when no kind is named.

groups() Dict[str, numpy.ndarray][source]

Return {label: values} while preserving frame order.

Preserving first occurrence keeps deliberately ordered experimental conditions, including controls, in their configured display order.

shape() str[source]

The data shape, for deciding which kinds fit.