spinetoolbox.widgets.plot_widget

A Qt widget showing a toolbar and a matplotlib plotting canvas.

Module Contents

Classes

PlotWidget

A widget that contains a toolbar and a plotting canvas.

_PlotDataView

Custom QTableView class with copy and paste methods.

_PlotDataWidget

Functions

prepare_plot_in_window_menu(menu)

Fills a given menu with available plot window names.

class spinetoolbox.widgets.plot_widget.PlotWidget(parent=None, legend_axes_position=LegendPosition.BOTTOM)[source]

Bases: PySide6.QtWidgets.QWidget

A widget that contains a toolbar and a plotting canvas.

canvas

the plotting canvas

Type

PlotCanvas

original_xy_data

unmodified data on which the plots are based

Type

list of XYData

Parameters
  • parent (QWidget, optional) – parent widget

  • legend_axes_position (LegendPosition) – legend axes position relative to plot axes

plot_windows[source]

A global list of plot windows.

closeEvent(event)[source]

Removes the window from plot_windows and closes.

contextMenuEvent(event)[source]

Shows plot context menu.

_get_plot_data()[source]

Gathers plot data into a table.

Returns

data as table

Return type

list of list

copy_plot_data()[source]

Copies plot data to clipboard.

show_plot_data()[source]

Opens a separate window that shows the plot data.

add_legend(handles)[source]

Adds a legend to the plot’s legend axes.

Parameters

handles (list) – legend handles

use_as_window(parent_window, document_name)[source]

Prepares the widget to be used as a window and adds it to plot_windows list.

Parameters
  • parent_window (QWidget) – a parent window

  • document_name (str) – a string to add to the window title

static _unique_window_name(document_name)[source]

Returns an unique identifier for a new plot window.

class spinetoolbox.widgets.plot_widget._PlotDataView(parent=None)[source]

Bases: spinetoolbox.widgets.custom_qtableview.CopyPasteTableView

Custom QTableView class with copy and paste methods.

contextMenuEvent(event)[source]
class spinetoolbox.widgets.plot_widget._PlotDataWidget(rows, parent=None)[source]

Bases: PySide6.QtWidgets.QWidget

set_size_according_to_parent()[source]

Sets the size of the widget according to the parent widget’s dimensions and the data in the table

spinetoolbox.widgets.plot_widget.prepare_plot_in_window_menu(menu)[source]

Fills a given menu with available plot window names.

Parameters

menu (QMenu) – menu to modify