0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 11:11:49 +02:00

docs(multi_waveform): docs added

This commit is contained in:
2024-11-04 12:56:21 +01:00
committed by wyzula_j
parent f3a39a69e2
commit 42d4f182f7
5 changed files with 126 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 432 KiB

View File

@ -0,0 +1,111 @@
(user.widgets.multi_waveform_widget)=
# Multi Waveform Widget
````{tab} Overview
The Multi Waveform Widget is designed to display multiple 1D detector signals over time. It is ideal for visualizing real-time streaming data from a monitor in the BEC framework, where each new data set is added as a new curve on the plot. This allows users to observe historical changes and trends in the signal.
## Key Features:
- **Real-Time Data Visualization**: Display multiple 1D signals from a monitor in real-time, with each new data set represented as a new curve.
- **Curve Management**: Control the number of curves displayed, set limits on the number of curves, and manage the buffer with options to flush old data.
- **Interactive Controls**: Highlight specific curves, adjust opacity, and interact with the plot using zoom and pan tools.
- **Customizable Appearance**: Customize the colormap, curve opacity, and highlight settings to enhance data visualization.
- **Data Export**: Export the displayed data for further analysis, including exporting to Matplotlib for advanced plotting.
- **Flexible Integration**: Can be integrated into both [`BECFigure`](user.widgets.bec_figure) and [`BECDockArea`](user.widgets.bec_dock_area), or used as an individual component in your application through `BECDesigner`.
````
````{tab} Examples - CLI
`BECMultiWaveform` can be embedded in both [`BECFigure`](user.widgets.bec_figure) and [`BECDockArea`](user.widgets.bec_dock_area), or used as an individual component in your application through `BECDesigner`. The command-line API is consistent across these contexts.
## Example 1 - Adding Multi Waveform to BECFigure
In this example, we demonstrate how to add a `MultiWaveform` plot to a `BECFigure` widget and connect it to a monitor.
```python
# Add a new dock and BECFigure to the GUI
fig = gui.add_dock().add_widget('BECFigure')
# Add a MultiWaveform plot to the figure and set the monitor
multi_waveform = fig.multi_waveform(monitor='waveform1d')
# Optionally, set plot properties
multi_waveform.set_title("Real-Time Multi Waveform")
multi_waveform.set_x_label("Time (s)")
multi_waveform.set_y_label("Amplitude")
```
## Example 2 - Using BECMultiWaveformWidget in BECDockArea
You can add `BECMultiWaveformWidget` directly to a `BECDockArea`. This widget includes its own toolbar and controls for interacting with the multi waveform plot.
```python
# Add a new BECMultiWaveformWidget to the BECDockArea
multi_waveform_widget = gui.add_dock().add_widget('BECMultiWaveformWidget')
# Set the monitor from the command line
multi_waveform_widget.set_monitor('waveform1d')
# Optionally, adjust settings
multi_waveform_widget.set_opacity(60)
multi_waveform_widget.set_curve_limit(100)
```
## Example 3 - Customizing the Multi Waveform Plot
You can customize various aspects of the plot, such as the colormap, opacity, and curve limit.
```python
# Change the colormap to 'viridis'
multi_waveform.set_colormap('viridis')
# Adjust the opacity of the curves to 70%
multi_waveform.set_opacity(70)
# Limit the number of curves displayed to 50
multi_waveform.set_curve_limit(50)
# Enable buffer flush when the curve limit is reached
multi_waveform.set_curve_limit(50, flush_buffer=True)
```
## Example 4 - Highlighting Curves
You can highlight specific curves to emphasize important data.
```python
# Disable automatic highlighting of the last curve
multi_waveform.set_highlight_last_curve(False)
# Highlight the third curve (indexing starts from 0)
multi_waveform.set_curve_highlight(2)
# Re-enable automatic highlighting of the last curve
multi_waveform.set_highlight_last_curve(True)
```
## Example 5 - Exporting Data
You can export the data from the multi waveform plot for further analysis.
```python
# Get all the data as a dictionary
data = multi_waveform.get_all_data(output='dict')
# Or get the data as a pandas DataFrame (if pandas is installed)
data_df = multi_waveform.get_all_data(output='pandas')
# Export the plot to Matplotlib for further customization
multi_waveform.export_to_matplotlib()
```
````
````{tab} API
```{eval-rst}
.. autoclass:: bec_widgets.widgets.figure.plots.multi_waveform.multi_waveform.BECMultiWaveform
:members:
:inherited-members:
```
```

View File

@ -45,6 +45,14 @@ Plotting widgets are used to display data in a graphical format.
Display 1D detector signals.
```
```{grid-item-card} Multi Waveform Widget
:link: user.widgets.multi_waveform_widget
:link-type: ref
:img-top: /assets/widget_screenshots/multi_waveform.png
Display multiple 1D waveforms.
```
```{grid-item-card} Image Widget
:link: user.widgets.image_widget
:link-type: ref
@ -241,6 +249,7 @@ hidden: true
dock_area/bec_dock_area.md
bec_figure/bec_figure.md
waveform/waveform_widget.md
multi_waveform/multi_waveform.md
image/image_widget.md
motor_map/motor_map.md
scan_control/scan_control.md
@ -248,7 +257,7 @@ progress_bar/ring_progress_bar.md
bec_status_box/bec_status_box.md
queue/queue.md
buttons_appearance/buttons_appearance.md
buttons_queue/buttons_queue.md
buttons_queue/button_queue.md
device_browser/device_browser.md
positioner_box/positioner_box.md
text_box/text_box.md
@ -257,6 +266,7 @@ toggle/toggle.md
spinner/spinner.md
bec_progressbar/bec_progressbar.md
device_input/device_input.md
signal_input/signal_input.md
position_indicator/position_indicator.md
lmfit_dialog/lmfit_dialog.md
dap_combo_box/dap_combo_box.md