photons.plotting module

Plot widget.

class photons.plotting.BaseTable(rows=0, header=None, parent=None, tooltip=None)[source]

Bases: QTableWidget

Custom table that has text-selectable, read-only cells.

resize_row_column(factor=1.5)[source]

Resize the width of the row-indicator column (the first column).

Return type:

None

class photons.plotting.BaseTableDelegate(parent)[source]

Bases: QItemDelegate

Allows for a table cell to be selectable and read only.

createEditor(parent, option, index)[source]

Overrides QtWidgets.QAbstractItemDelegate.createEditor().

Return type:

QLineEdit

class photons.plotting.LogTable(log_dataset, title)[source]

Bases: BaseTable

Display the logging records in a table.

COLORS: dict[str, QColor] = {'CRITICAL': PySide6.QtGui.QColor.fromRgbF(1.000000, 0.000000, 0.000000, 1.000000), 'DEBUG': PySide6.QtGui.QColor.fromRgbF(0.466667, 0.533333, 0.600000, 1.000000), 'ERROR': PySide6.QtGui.QColor.fromRgbF(0.545098, 0.000000, 0.000000, 1.000000), 'INFO': PySide6.QtGui.QColor.fromRgbF(0.000000, 0.000000, 0.000000, 1.000000), 'NOTSET': PySide6.QtGui.QColor.fromRgbF(1.000000, 1.000000, 1.000000, 1.000000), 'WARNING': PySide6.QtGui.QColor.fromRgbF(0.721569, 0.525490, 0.043137, 1.000000)}
class photons.plotting.MetadataTable(tooltip=None)[source]

Bases: BaseTable

Display metadata in a table.

add(metadata)[source]

Add a row to the table.

Return type:

None

class photons.plotting.Plot(root=None, parent=None, **kwargs)[source]

Bases: QWidget

A widget for plotting 2D data and displaying metadata.

Parameters:
  • root (Root) – A Root object.

  • parent (QWidget) – The parent widget.

  • **kwargs – All keyword arguments are passed to super().

dragEnterEvent(event)[source]

Overrides QtWidgets.QWidget.dragEnterEvent().

Return type:

None

dropEvent(event)[source]

Overrides QtWidgets.QWidget.dropEvent().

Return type:

None

new_root()[source]

A new Root has been dropped.

Return type:

None

on_clear_plot()[source]

Clear the scatter plot.

Return type:

None

on_dataset_changed(name)[source]

A new dataset was selected.

Return type:

None

on_replot()[source]

Replot the currently-selected data.

Return type:

None

on_screenshot()[source]

Save a screenshot of the Plot widget.

Return type:

None

should_clear_plot()[source]

Whether the plots should be cleared.

Return type:

bool

class photons.plotting.ScatterPlot(parent)[source]

Bases: QWidget

A scatter-plot for a 2D dataset.

clear()[source]

Clear all plots.

Return type:

None

static hovering(x_text)[source]

Callback function for a mouse hover.

Return type:

Callable[[float, float, float | None], str]

on_y_range_checkbox_clicked(state)[source]

Enable or disable the min-max widgets for the Y axis.

Return type:

None

redraw(ignore=None)[source]

Redraw the plot.

Return type:

None

set_dataset(dataset)[source]

A different dataset was selected in the combobox.

Return type:

None

class photons.plotting.RealTimePlot(*, error_options=None, plot_options=None, signaler=None, size=10000, title=None)[source]

Bases: QWidget

Plot data in real time.

Parameters:
  • error_options (dict) – Options passed to ErrorBarItem. If not specified, default options are used.

  • plot_options (dict) – Options passed to PlotItem. If not specified, default options are used.

  • signaler (SignalInstance) – The Qt signal that emits Samples.

  • size (int) – The maximum number of data points that can be shown. When the number of data points exceeds this value the latest data point is shown and the oldest data point is removed.

  • title (str) – The text to display in the titlebar of the widget.

closing: SignalInstance

Emitted when the widget closes.

clear()[source]

Clear the plot.

Return type:

None

update(samples)[source]

Update the plot.

If a signaler is specified when this class is instantiated, this method (slot) is called automatically when the signaler emits the samples.

Parameters:

samples (Samples) – The data to add to the plot. The standard deviation of the mean is used as the error bar.

Return type:

None

closeEvent(event)[source]

Overrides QtWidgets.QWidget.closeEvent().

Disconnect from the signaler (if one was specified), removes items from the plot and emits the closing signal.

Return type:

None