plesty.lib.ui.qt.plot

pyqtgraph renderer: draws a monitor’s declared traces into a Qt widget.

This is the only place in the platform that knows both a Monitor and a plotting library. The monitor declares what it draws (TraceSpec) and hands over what to draw (TraceData); this module turns that into plot items and keeps them fed. pyqtgraph is used because a trace fed every few hundred milliseconds for hours must redraw without the operator noticing.

Colours never appear here as literals: every pen comes from the Theme, which reads the packaged palette.

Classes

PlotRenderer

Draw target that renders a monitor's traces into a pyqtgraph widget.

Functions

_lookup_table(→ numpy.ndarray)

Build the image lookup table from the theme's colour-map stops.

Module Contents

plesty.lib.ui.qt.plot._lookup_table(theme: plesty.lib.ui.theme.Theme) numpy.ndarray

Build the image lookup table from the theme’s colour-map stops.

Parameters:

theme (plesty.lib.ui.theme.Theme)

Return type:

numpy.ndarray

class plesty.lib.ui.qt.plot.PlotRenderer(theme: plesty.lib.ui.theme.Theme | None = None, parent: PySide6.QtWidgets.QWidget | None = None)

Bases: plesty.lib.monitor.base_monitor.Renderer

Draw target that renders a monitor’s traces into a pyqtgraph widget.

The renderer owns its widget (widget), so a panel builds one and hands the widget to the shell:

renderer = PlotRenderer(theme)
monitor.attach(renderer)      # builds the plot items, replays the last data
shell_panel_widget = renderer.widget

Create the plot widget.

Parameters:
  • theme (Optional[plesty.lib.ui.theme.Theme]) – Palette to resolve trace colours and chrome against; None loads the packaged PLESTY theme.

  • parent (Optional[PySide6.QtWidgets.QWidget]) – Parent widget.

theme
widget
plot
caption
_items: dict[str, Any]
_images: dict[str, pyqtgraph.ImageItem]
_texts: dict[str, str]
_lut
setup(monitor: plesty.lib.monitor.base_monitor.Monitor) None

Build one plot item per declared trace.

Parameters:

monitor (plesty.lib.monitor.base_monitor.Monitor) – The monitor that was attached.

Return type:

None

draw(monitor: plesty.lib.monitor.base_monitor.Monitor, data: dict[str, plesty.lib.monitor.base_monitor.TraceData]) None

Feed new payloads into the plot items.

Parameters:
Return type:

None

clear(monitor: plesty.lib.monitor.base_monitor.Monitor) None

Empty every plot item without rebuilding them.

Parameters:

monitor (plesty.lib.monitor.base_monitor.Monitor) – The monitor whose view is being reset.

Return type:

None

_style_plot() None

Apply the theme to the plot background, axes, and grid.

Return type:

None

_build_item(spec: plesty.lib.monitor.base_monitor.TraceSpec, index: int) None

Create the plot item declared by one trace spec.

Parameters:
Return type:

None

_draw_curve(key: str, payload: plesty.lib.monitor.base_monitor.TraceData) None

Update one line or scatter trace.

Parameters:
Return type:

None

_draw_image(key: str, payload: plesty.lib.monitor.base_monitor.TraceData) None

Update one image trace, scaling it onto its physical axes.

Parameters:
Return type:

None

_draw_text(key: str, spec: plesty.lib.monitor.base_monitor.TraceSpec, payload: plesty.lib.monitor.base_monitor.TraceData) None

Record a scalar or text trace for the caption line under the plot.

Parameters:
Return type:

None