plotting
¶
Functions for plotting on PlotWidget.
Currently plotting from the table views found in Graph, Tree and Tabular views are supported.
The main entrance points to plotting are: - plot_selection() which plots selected cells on a table view returning a PlotWidget object - plot_pivot_column() which is a specialized method for plotting entire columns of a pivot table - add_time_series_plot() which adds a time series plot to an existing PlotWidget
author: |
|
---|---|
date: | 9.7.2019 |
Module Contents¶
-
exception
plotting.
PlottingError
(message)[source]¶ Bases:
Exception
An exception signalling failure in plotting.
-
message
[source] Returns the error message.
-
-
plotting.
_raise_if_types_inconsistent
(values)[source]¶ Raises an exception if not all values are TimeSeries or floats.
-
plotting.
_filter_name_columns
(selections)[source]¶ Returns a dict with all but the entry with the greatest key removed.
-
plotting.
_organize_selection_to_columns
(indexes)[source]¶ Organizes a list of model indexes into a dictionary of {column: (rows)} entries.
-
plotting.
_collect_single_column_values
(model, column, rows, hints)[source]¶ Collects selected parameter values from a single column in a PivotTableModel.
The return value of this function depends on what type of data the given column contains. In case of plain numbers, a list of floats and a single label string are returned. In case of time series, a list of TimeSeries objects is returned, accompanied by a list of labels, each label corresponding to one of the time series.
Parameters: - model (QAbstractTableModel) – a table model
- column (int) – a column index to the model
- rows (Sequence) – row indexes to plot
- hints (PlottingHints) – a plot support object
Returns: a tuple of values and label(s)
-
plotting.
_collect_column_values
(model, column, rows, hints)[source]¶ Collects selected parameter values from a single column in a PivotTableModel for plotting.
The return value of this function depends on what type of data the given column contains. In case of plain numbers, a single tuple of two lists of x and y values and a single label string are returned. In case of time series, a list of TimeSeries objects is returned, accompanied by a list of labels, each label corresponding to one of the time series.
Parameters: - model (QAbstractTableModel) – a table model
- column (int) – a column index to the model
- rows (Sequence) – row indexes to plot
- hints (PlottingHints) – a support object
Returns: a tuple of values and label(s)
-
plotting.
plot_pivot_column
(model, column, hints)[source]¶ Returns a plot widget with a plot of an entire column in PivotTableModel.
Parameters: - model (PivotTableModel) – a pivot table model
- column (int) – a column index to the model
- hints (PlottingHints) – a helper needed for e.g. plot labels
Returns: a PlotWidget object
-
plotting.
plot_selection
(model, indexes, hints)[source]¶ Returns a plot widget with plots of the selected indexes.
Parameters: - model (QAbstractTableModel) – a model
- indexes (Iterable) – a list of QModelIndex objects for plotting
- hints (PlottingHints) – a helper needed for e.g. plot labels
Returns: a PlotWidget object
-
plotting.
add_time_series_plot
(plot_widget, value, label=None)[source]¶ Adds a time series step plot to a plot widget.
Parameters: - plot_widget (PlotWidget) – a plot widget to modify
- value (TimeSeries) – the time series to plot
- label (str) – a label for the time series
-
plotting.
tree_graph_view_parameter_value_name
(index, table_view)[source]¶ Returns a label for Tree or Graph view table cell.
Parameters: - index (QModelIndex) – an index to the table model
- table_view (QTableView) – a table view widget corresponding to index
Returns: a unique name for the parameter value as a string
-
class
plotting.
PlottingHints
[source]¶ A base class for plotting hints.
The functionality in this class allows the plotting functions to work without explicit knowledge of the underlying table model or widget.
-
filter_columns
(self, selections, model)[source]¶ Filters columns and returns the filtered selections.
-
is_index_in_data
(self, model, index)[source]¶ Returns true if the cell given by index is actually plottable data.
-
-
class
plotting.
GraphAndTreeViewPlottingHints
(table_view)[source]¶ Bases:
plotting.PlottingHints
Support for plotting data in Graph and Tree views.
-
table_view
¶ a parameter value or definition widget
Type: QTableView
-
cell_label
(self, model, index)[source]¶ Returns a label build from the columns on the left from the data column.
-
-
class
plotting.
PivotTablePlottingHints
[source]¶ Bases:
plotting.PlottingHints
Support for plotting data in Tabular view.
-
is_index_in_data
(self, model, index)[source]¶ Returns True if index is in the data portion of the table.
-