bec_widgets.widgets.plots.plot_base#
Classes#
Bases: |
|
Mixin class for all BEC widgets, to handle cleanup |
|
Create a collection of name/value pairs. |
Module Contents#
- class BECViewBox(parent=None, border=None, lockAspect=False, enableMouse=True, invertY=False, enableMenu=True, name=None, invertX=False, defaultPadding=0.02)#
Bases:
pyqtgraph.ViewBoxBases:
GraphicsWidgetBox that allows internal scaling/panning of children by mouse drag. This class is usually created automatically as part of a
PlotItemor Canvas or withGraphicsLayout.addViewBox().Features:
Scaling contents by mouse or auto-scale when contents change
View linking–multiple views display the same data ranges
Configurable by context menu
Item coordinate mapping methods
Arguments:
parent
(QGraphicsWidget) Optional parent widget
border
(QPen) Do draw a border around the view, give any single argument accepted by
mkPenlockAspect
(False or float) The aspect ratio to lock the view coorinates to. (or False to allow the ratio to change)
enableMouse
(bool) Whether mouse can be used to scale/pan the view
invertY
(bool) See
invertYinvertX
(bool) See
invertXenableMenu
(bool) Whether to display a context menu when right-clicking on the ViewBox background.
name
(str) Used to register this ViewBox so that it appears in the “Link axis” dropdown inside other ViewBox context menus. This allows the user to manually link the axes of any other view to this one.
defaultPadding
(float) fraction of the data range that will be added as padding by default
- itemBoundsChanged(item)#
- paint(painter, opt, widget)#
- sigPaint#
- class PlotBase(parent: qtpy.QtWidgets.QWidget | None = None, config: bec_widgets.utils.ConnectionConfig | None = None, client=None, gui_id: str | None = None, popups: bool = True, **kwargs)#
Bases:
bec_widgets.utils.bec_widget.BECWidget,qtpy.QtWidgets.QWidgetMixin class for all BEC widgets, to handle cleanup
Base class for all BEC widgets. This class should be used as a mixin class for all BEC widgets, e.g.:
>>> class MyWidget(BECWidget, QWidget): >>> def __init__(self, parent=None, client=None, config=None, gui_id=None): >>> super().__init__(parent=parent, client=client, config=config, gui_id=gui_id)
- Parameters:
client (BECClient, optional) – The BEC client.
config (ConnectionConfig, optional) – The connection configuration.
gui_id (str, optional) – The GUI ID.
theme_update (bool, optional) – Whether to subscribe to theme updates. Defaults to False. When set to True, the widget’s apply_theme method will be called when the theme changes.
- _apply_autorange_only_visible_curves()#
Apply autorange to the plot item based on the provided curves.
- Parameters:
curves (list) – List of curves to apply autorange to.
- _apply_x_label()#
Actually updates the pyqtgraph axis label text to the combined label. Called whenever user label or suffix changes.
- _apply_y_label()#
Actually updates the pyqtgraph y axis label text to the combined y label. Called whenever y label or suffix changes.
- _init_toolbar()#
- _init_ui()#
- _tuple_to_qpointf(tuple: PlotBase._tuple_to_qpointf.tuple | list)#
Helper function to convert a tuple to a QPointF.
- Parameters:
tuple (tuple|list) – Tuple or list of two numbers.
- Returns:
The tuple converted to a QPointF.
- Return type:
QPointF
Adds multiple menus to the side panel.
- apply_theme(theme: str)#
Apply the theme to the widget.
- Parameters:
theme (str, optional) – The theme to be applied.
- auto_range(value: bool = True)#
On demand apply autorange to the plot item based on the visible curves.
- Parameters:
value (bool) – If True, apply autorange to the visible curves.
- auto_range_x() bool#
Set auto range for the x-axis.
- auto_range_y() bool#
Set auto range for the y-axis.
- cleanup()#
Cleanup the widget.
- cleanup_pyqtgraph(item: pyqtgraph.PlotItem | None = None)#
Cleanup pyqtgraph items.
- enable_fps_monitor() bool#
Enable the FPS monitor.
- enable_popups()#
Enable popups setting dialogs for the plot widget.
- enable_side_panel() bool#
Show Side Panel
- enable_toolbar() bool#
Show Toolbar.
- hook_crosshair() None#
Hook the crosshair to all plots.
- hook_fps_monitor()#
Hook the FPS monitor to the plot.
- inner_axes() bool#
Show inner axes of the plot widget.
- invert_x() bool#
Invert X axis.
- invert_y() bool#
Invert Y axis.
- legend_label_size() int#
The font size of the legend font.
- lock_aspect_ratio() bool#
Lock aspect ratio of the plot widget.
- minimal_crosshair_precision() int#
Minimum decimal places for crosshair when dynamic precision is enabled.
- outer_axes() bool#
Show the outer axes of the plot widget.
- reset() None#
Reset the plot widget.
- reset_legend()#
In the case that the legend is not visible, reset it to be visible to top left corner
- set(**kwargs)#
Set the properties of the plot widget.
- Parameters:
**kwargs – Keyword arguments for the properties to be set.
- Possible properties:
title: str
x_label: str
y_label: str
x_scale: Literal[“linear”, “log”]
y_scale: Literal[“linear”, “log”]
x_lim: tuple
y_lim: tuple
legend_label_size: int
- set_x_label_suffix(suffix: str)#
Public or protected method to update the suffix. The user code or subclass (Waveform) can call this when x_mode changes, but the AxisSettings won’t show it.
- set_y_label_suffix(suffix: str)#
Public method to update the y label suffix.
- title() str#
Set title of the plot.
- toggle_crosshair() None#
Toggle the crosshair on all plots.
- unhook_crosshair() None#
Unhook the crosshair from all plots.
- unhook_fps_monitor(delete_label=True)#
Unhook the FPS monitor from the plot.
- update_fps_label(fps: float) None#
Update the FPS label.
- Parameters:
fps (float) – The frames per second.
- viewbox_state_changed()#
Emit a signal when the state of the viewbox has changed. Merges the default pyqtgraphs signal states and also CTRL menu toggles.
- x_grid() bool#
Show grid on the x-axis.
- x_label() str#
The set label for the x-axis.
- x_limits() qtpy.QtCore.QPointF#
Get the x limits of the plot.
- x_log() bool#
Set X-axis to log scale if True, linear if False.
- y_grid() bool#
Show grid on the y-axis.
- y_label() str#
The set label for the y-axis.
- y_limits() qtpy.QtCore.QPointF#
Get the y limits of the plot.
- y_log() bool#
Set Y-axis to log scale if True, linear if False.
- BASE_USER_ACCESS = ['enable_toolbar', 'enable_toolbar.setter', 'enable_side_panel', 'enable_side_panel.setter',...#
- PLUGIN = False#
- RPC = False#
- USER_ACCESS = ['remove', 'attach', 'detach', 'enable_toolbar', 'enable_toolbar.setter', 'enable_side_panel',...#
- arrow_item#
- axis_settings_dialog = None#
- crosshair = None#
- crosshair_coordinates_changed#
- crosshair_coordinates_clicked#
- crosshair_position_changed#
- crosshair_position_clicked#
- entry_validator#
- fps_label#
- fps_monitor = None#
- layout#
- layout_manager#
- plot_item#
- plot_widget#
- property_changed#
- side_panel#
- state_manager#
- tick_item#
- toolbar#
- property visible_items#
- property x_label_combined: str#
The final label shown on the axis = user portion + suffix + [units].
- property x_label_suffix: str#
A read-only (or internal) suffix automatically appended to the user label. Not settable by the user directly from the UI.
- property x_label_units: str#
The units of the x-axis.
- property x_lim: tuple#
Get the x limits of the plot.
- property x_max: float#
Get the maximum x limit of the plot.
- property x_min: float#
Get the minimum x limit of the plot.
- property y_label_combined: str#
The final y label shown on the axis = user portion + suffix + [units].
- property y_label_suffix: str#
A read-only suffix automatically appended to the y label.
- property y_label_units: str#
The units of the y-axis.
- property y_lim: tuple#
Get the y limits of the plot.
- property y_max: float#
Get the maximum y limit of the plot.
- property y_min: float#
Get the minimum y limit of the plot.
- class UIMode(*args, **kwds)#
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- NONE = 0#
- POPUP = 1#
- SIDE = 2#