stoner_measurement.plugins.command.plot_points.PlotPointsCommand

class stoner_measurement.plugins.command.plot_points.PlotPointsCommand(parent=None)[source]

Bases: CommandPlugin

Append live data points to one or more plot traces.

Use this command inside loops or repeated measurement sections when you want to build up a plot point-by-point during the run. It is especially useful for live displays of quantities such as resistance vs temperature, voltage vs field, or any other scalar value against another scalar value already available in the sequence value catalogue.

Plot form defaults to XY. A display with the appropriate capabilities also offers XYZ, XY intensity, or XYZ + value. These forms have independent X/Y scalar sources or expressions and a scrollable list of measured Z entries. Each entry has its own source, displayed label, surface identity expression and optional uncertainty expression. XYZ + value adds an explicit independent scalar for colour. The coordinate controls specify source meanings and angular conventions without projecting acquisition data.

Polar (angle, radius) appends one angular sample per execution. Its first input is independent Angle data, typically motor position; its second is dependent Radius data, such as resistance. Choose catalogue sources or runtime scalar expressions. Angle source units default to degrees with radians selectable. Separate controls set uncertainties, title/series ID, origin, clockwise orientation, wrapping and colour/line/point styles. Use separate Plot Points steps to show multiple radial responses.

Surface forms map exact X/Y pairs to rectilinear cells, so reverse or serpentine nested loops retain the correct grid. Repeated cells are rejected unless replace is selected; missing cells remain absent. Clear the plot for a new run, or change the acquisition identity with reset explicitly enabled. Display changes refresh available forms and axes immediately. Unsupported saved forms stay visible and retain all bindings. Legacy Y entries and axis/style controls continue to apply to XY only.

In the configuration panel you choose:

  • one X value

  • one or more Y series

  • optional trace labels

  • which plot axes those series should use

  • optional formatting such as colour, line style, marker style, and sizes

The configuration tab therefore acts as a small live-plot series editor. One control chooses the x source, while a scrollable list of y-series rows lets you add or remove plotted quantities and customise their presentation. The Help/About tab uses this docstring to explain how catalogue keys, axis names, and style overrides affect the emitted live plot updates.

Each time the command runs, it reads the current scalar x value and the current scalar y value for each configured series, then appends those points to the plot. New axes are created automatically if you assign a series to an axis name that does not already exist.

Variables:
  • plot_form (str) – xy, polar, xyz, xy_intensity or xyz_value; defaults to xy.

  • polar_radius_expr (polar_angle_expr,) – Runtime scalars for independent angle and dependent radius.

  • polar_radius_error_expr (polar_angle_error_expr,) – Optional scalar uncertainties in the source units.

  • polar_settings (dict) – Angular units (degrees by default), origin, clockwise and wrapping. Zero defaults to the top and increasing angles run clockwise.

  • polar_title_expr (polar_id_expr,) – Runtime series identity and displayed title. The automatic ID is unique and persistent; clear the plot before starting a new run.

  • polar_style (dict) – Independent colour, line/point style and size overrides.

  • coordinate_y_expr (new_x_expr,) – Separate runtime scalar coordinate expressions for additional forms.

  • z_entries (list[dict]) – Explicit measured channels with expr (or key in _values), label, surface_id_expr and optional error_expr. Each identity expression must return a distinct nonblank string, independent of the label.

  • value_expr (str) – Independent scalar colour expression, used only by xyz_value.

  • acquisition_id_expr (str) – Runtime string run identity, defaulting to ‘default’.

  • duplicate_policy (str) – reject (default) or replace repeated coordinate cells.

  • reset_on_change (bool) – Permit a new acquisition identity to reset the grid; default False.

  • coordinate_settings (dict) – Explicit CoordinateDescriptor fields, including angular units, wrapping, origin, orientation and spherical angle convention.

  • x_key (str) – Key in the _values catalogue for the x data. The current value is read each time the command executes.

  • y_entries (list[dict[str, str]]) – Ordered list of y-series definitions. Each entry is a dict with keys "key" (catalogue key), "label" (trace name shown in the legend), "y_axis" (y-axis name; defaults to "left" when absent), and optional format keys "colour", "line_style", "point_style", "line_width", and "point_size". Empty string values and 0.0 numeric values mean “use the plot panel default”.

  • x_axis_name (str) – Name of the x-axis shared by all y series. Defaults to "bottom".

  • plot_point (pyqtSignal[str, float, float]) – Emitted once per y series by execute() as (label, x_value, y_value). Automatically connected to append_point() when the plugin is attached to an engine with a plot widget.

  • plot_trace_style (pyqtSignal[str, object]) – Emitted once per y series by execute() as (label, style_dict) when format overrides are configured for that series. Automatically connected to set_trace_style_from_dict() when the plugin is attached to an engine with a plot widget.

  • instance_name (str) – Inherited Python identifier for this instance in the Script tab and QtConsole.

  • comment (str) – Inherited optional note displayed beside this step.

  • sequence_engine (SequenceEngine | None) – Inherited owning engine and its live namespace; None while detached.

Keyword Parameters:

parent (QObject | None) – Optional Qt parent object.

Examples

With an instance named plot_points in the sequence, use the QtConsole to inspect or edit it before running. Substitute your instance name if different; result data reflects completed steps:

plot_points.x_key = "counter:Value"
plot_points.y_entries = [{"key": "set_temperature:Temperature"}]

With Polar traces selected and existing motor and voltmeter instances in the live namespace (use their actual instance names):

plot_points.plot_form = "polar"
plot_points.polar_angle_expr = "motor.position"
plot_points.polar_radius_expr = "voltmeter.value"
plot_points.polar_settings = {
    "angular_unit": "degrees",
    "angular_origin": 90,
    "clockwise": True,
}

For an installed display advertising surface assembly:

plot_points.plot_form = "xyz"
plot_points.new_x_expr = "field.current_value"
plot_points.coordinate_y_expr = "temperature.current_value"
plot_points.z_entries = [{
    "expr": "voltmeter.value", "label": "Voltage",
    "surface_id_expr": "'field-temperature'",
}]
config_widget(parent: QWidget | None = None) → QWidget[source]

Return a settings widget for configuring the plot-points command.

The widget contains:

  • An X value dropdown populated from the _values catalogue.

  • An X axis dropdown for the shared x-axis.

  • A scrollable list of Y series rows, each with a value dropdown, a label line-edit (defaulting to "{quantity name} ({units})") an editable Y axis dropdown, and a Remove button.

  • An Add Y series button that appends a new row.

Keyword Parameters:

parent (QWidget | None) – Optional Qt parent widget.

Returns:

The settings widget for the PlotPoints configuration tab.

Return type:

(QWidget)

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.plot_points import PlotPointsCommand
>>> from qtpy.QtWidgets import QWidget
>>> isinstance(PlotPointsCommand().config_widget(), QWidget)
True
execute() → None[source]

Read x and y scalar values and emit plot_point for each y series.

For each entry in y_entries, the x value (from x_key) and the y value (from the entry’s "key") are evaluated against the engine namespace and plot_point is emitted as (label, x_value, y_value). The trace is then assigned to the axes specified by x_axis_name and the entry’s "y_axis" field. If the specified y-axis does not yet exist on the plot widget it is created automatically (on the right-hand side).

Missing or unconfigured keys are logged as warnings and the corresponding series is skipped. Polar and surface updates are skipped when an input expression fails or returns an unavailable scalar value.

Raises:

TimeoutError – If the plot widget does not acknowledge a queued point update before the response timeout expires.

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.plot_points import PlotPointsCommand
>>> from stoner_measurement.core.sequence_engine import SequenceEngine
>>> engine = SequenceEngine()
>>> cmd = PlotPointsCommand()
>>> engine.add_plugin("plot_points", cmd)
>>> received = []
>>> cmd.plot_point.connect(lambda l, x, y: received.append((l, x, y)))
>>> engine._namespace["_values"] = {"p:x": "p_x_val", "p:y": "p_y_val"}
>>> engine._namespace["p_x_val"] = 1.0
>>> engine._namespace["p_y_val"] = 2.0
>>> cmd.x_key = "p:x"
>>> cmd.y_entries = [{"key": "p:y", "label": "My Y"}]
>>> cmd.execute()
>>> received
[('My Y', 1.0, 2.0)]
>>> engine.shutdown()
property name: str

Unique identifier for the plot-points command.

Returns:

"Plot Points".

Return type:

(str)

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.plot_points import PlotPointsCommand
>>> PlotPointsCommand().name
'Plot Points'
plot_context_changed

Signal emitted when the owning engine/client endpoint changes.

plot_ensure_x_axis

Signal emitted by execute() to ensure x-axis exists — (axis_name, axis_label).

plot_ensure_y_axis

Signal emitted by execute() to ensure y-axis exists — (axis_name, axis_label).

plot_point

XY data signal; additional forms submit complete portable requests.

plot_rename_trace

Signal emitted when a configured series label changes — (old_name, new_name).

plot_trace_axes

Signal emitted by execute() to assign trace axes — (trace_name, x_axis, y_axis).

plot_trace_style

Signal emitted by execute() to set trace style — (trace_name, style_dict).

plot_update_queued

Signal emitted by execute() before each queued point update.

property sequence_engine: SequenceEngine | None

Active sequence engine, or None when the plugin is detached.

Overrides the class-level attribute from BasePlugin with a full property so that the setter can automatically connect the plot_point signal to the engine’s plot widget.

Returns:

The owning engine, or None if not attached.

Return type:

(SequenceEngine | None)

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.plot_points import PlotPointsCommand
>>> from stoner_measurement.core.sequence_engine import SequenceEngine
>>> engine = SequenceEngine()
>>> cmd = PlotPointsCommand()
>>> cmd.sequence_engine is None
True
>>> engine.add_plugin("plot_points", cmd)
>>> cmd.sequence_engine is engine
True
>>> engine.shutdown()
to_json() → dict[str, Any][source]

Serialise the plot-points command configuration to a JSON-compatible dict.

Returns:

Base dict from to_json() extended with "x_key", "x_axis_name", and "y_entries" (each entry includes "y_axis" and optional format fields "colour", "line_style", "point_style", "line_width", and "point_size").

Return type:

(dict[str, Any])

Examples

>>> from qtpy.QtWidgets import QApplication
>>> _ = QApplication.instance() or QApplication([])
>>> from stoner_measurement.plugins.command.plot_points import PlotPointsCommand
>>> d = PlotPointsCommand().to_json()
>>> d["type"]
'command'
>>> "x_key" in d and "y_entries" in d
True