|
1 | 1 | # Live pyqtgraph plot
|
2 | 2 |
|
3 |
| -Pglive package adds support for thread-safe live plotting to pyqtgraph. |
4 |
| -It supports PyQt5, PyQt6, PySide2 and PySide6. |
| 3 | +Pglive package adds support for thread-safe live plotting based on pyqtgraph. |
| 4 | +It supports PyQt5, PyQt6 and PySide6. |
5 | 5 |
|
6 | 6 | # Description #
|
7 | 7 |
|
8 |
| -By default, pyqtgraph doesn't support live plotting. Aim of this package is to provide easy implementation of Line, |
9 |
| -Scatter and Bar Live plot. Every plot is connected with it's DataConnector, which sole purpose is to consume data points |
10 |
| -and manage data re-plotting. DataConnector interface provides Pause and Resume method, update rate and maximum number of |
11 |
| -plotted points. Each time data point is collected, call `DataConnector.cb_set_data` |
12 |
| -or `DataConnector.cb_append_data_point` callback. That's all You need to update plot with new data. Callbacks are Thread |
13 |
| -safe, so it works nicely in applications with multiple data collection Threads. |
| 8 | +Pyqtgraph doesn't offer easy way to implement live plotting out of the box. |
| 9 | +The aim of PgLive module is to provide easy way of thread-safe live plotting. |
| 10 | +To do this, PgLive provides DataConnector object, which consumes data |
| 11 | +and manages data plotting. DataConnector interface provides Pause and Resume method, update rate and maximum number of |
| 12 | +plotted points. All that needs to be done is to connect plots and data sources with DataConnector. |
| 13 | +Once data is collected, DataConnector is sending signals to the GUI main loop. |
14 | 14 |
|
15 |
| -**Focus on data collection and leave plotting to pglive.** |
| 15 | +**Focus on data handling - leave plotting to pglive.** |
16 | 16 |
|
17 |
| -To make firsts steps easy, package comes with many examples implemented in PyQt5 or PyQt6. |
18 |
| -Support for PySide2 and PySide6 was added in version 0.3.0. |
| 17 | +You can find many examples for PyQt5, PyQt6 or PySide6. |
19 | 18 |
|
20 |
| -# Code examples # |
| 19 | +# Code example # |
21 | 20 |
|
22 | 21 | ```python
|
23 | 22 | import sys
|
@@ -52,11 +51,11 @@ def sin_wave_generator(connector):
|
52 | 51 | data_point = sin(x * 0.01)
|
53 | 52 | # Callback to plot new data point
|
54 | 53 | connector.cb_append_data_point(data_point, x)
|
55 |
| - |
56 | 54 | sleep(0.01)
|
57 | 55 |
|
58 | 56 |
|
59 | 57 | plot_widget.show()
|
| 58 | +# Start sin_wave_generator in new Thread and send data to data_connector |
60 | 59 | Thread(target=sin_wave_generator, args=(data_connector,)).start()
|
61 | 60 | app.exec()
|
62 | 61 | running = False
|
@@ -92,47 +91,54 @@ Pglive supports four plot types: `LiveLinePlot`, `LiveScatterPlot`, `LiveHBarPlo
|
92 | 91 | Scaling plot view to plotted data has a huge impact on plotting performance.
|
93 | 92 | Re-plotting might be laggy when using high update frequencies and multiple plots.
|
94 | 93 | To increase plotting performance, pglive introduces `LiveAxisRange`, that can be used in `LivePlotWidget`.
|
95 |
| -User can now specify when and how is new view of plotted data calculated. |
| 94 | +User can specify when and how is a new view of plotted data calculated. |
96 | 95 |
|
97 |
| -Have a look in the `live_plot_range.py` example, to see how it can be used. |
| 96 | +Have a look in the [live_plot_range.py](https://github.com/domarm-comat/pglive/blob/main/pglive/examples_pyqt6/live_plot_range.py) example. |
98 | 97 |
|
99 | 98 | 
|
100 | 99 |
|
101 |
| -In case you want to plot wider area with LiveAxisRange you can use crop_offset_to_data flag. |
| 100 | +In case you want to plot wider area with LiveAxisRange you can use `crop_offset_to_data` flag. |
102 | 101 | For example, you want to store 60 seconds, display 30 seconds in a view and move view every 1 second.
|
103 |
| -You will have big empty space to the left without setting flag to True. |
104 |
| -Have a look into crop_offset_to_data example. |
| 102 | +You will end up with big empty space to the left if `crop_offset_to_data = False`. |
| 103 | +Take a look into [crop_offset_to_data.py](https://github.com/domarm-comat/pglive/blob/main/pglive/examples_pyqt6/crop_offset_to_data.py) example. |
105 | 104 |
|
106 | 105 | 
|
107 | 106 |
|
108 | 107 | Introduced in *v0.4.0*
|
109 | 108 |
|
110 | 109 | # Crosshair #
|
111 | 110 |
|
112 |
| -Pglive comes with built-in Crosshair as well. |
| 111 | +Pglive comes with built-in Crosshair as well. Take a look at [crosshair.py](https://github.com/domarm-comat/pglive/blob/main/pglive/examples_pyqt6/crosshair.py) example. |
113 | 112 |
|
114 | 113 | 
|
115 | 114 |
|
116 | 115 | # Leading lines #
|
117 | 116 |
|
118 | 117 | Leading line displays horizontal or vertical line (or both) at the last plotted point.
|
119 |
| -You can choose it's color and which axis value is displayed along with it. |
| 118 | +You can choose its color and which axis value is displayed along with it. |
| 119 | +Example at [leading_line.py](https://github.com/domarm-comat/pglive/blob/main/pglive/examples_pyqt6/leading_line.py) |
120 | 120 |
|
121 | 121 | 
|
122 | 122 |
|
123 | 123 | # Axis #
|
124 | 124 |
|
125 |
| -To make life easier, pglive includes few axis improvements: |
| 125 | +To make life easier, pglive includes a few axis improvements: |
126 | 126 |
|
127 | 127 | - Colored axis line using new `axisPen` attribute
|
128 | 128 | - Time and DateTime tick format, converting timestamp into human-readable format
|
129 |
| -- Use `tick_angle` attribute to change tick angle from 0 default degree |
| 129 | +- Use `tick_angle` attribute to change tick angle from 0 default degree |
| 130 | + |
| 131 | +Example at [axis.py](https://github.com/domarm-comat/pglive/blob/main/pglive/examples_pyqt6/axis.py) |
130 | 132 |
|
131 | 133 | [](https://postimg.cc/RqBy04V6)
|
132 | 134 |
|
133 | 135 | # Summary #
|
134 | 136 |
|
135 |
| -- With Pglive You've got easy Thread-safe implementation of fast Live plots |
136 |
| -- You can use all `kwargs` specified in pyqtgraph |
137 |
| -- Use your pyqtgraph plots with `DataConnector` directly, no need to use specific `LivePlot` class |
138 |
| -- **Focus on Data Handling, not Data Plotting** |
| 137 | +- With Pglive You've got an easy Thread-safe live plot implementation in Pyqt5, Pyqt6 or PySide6 |
| 138 | +- It works from Python3.9 and in Python3.12 as well |
| 139 | +- You can use all `kwargs` that works in [pyqtgraph](https://pyqtgraph.readthedocs.io/en/latest/getting_started/index.html#getting-started-ref) |
| 140 | +- Use your pyqtgraph plots with `DataConnector` directly |
| 141 | +- **Focus on Data Handling, not Data Plotting** |
| 142 | + |
| 143 | +If you find PgLive helpful, please consider [supporting me](https://ko-fi.com/domarmcomatsk), it helps a lot! |
| 144 | +Thanks to all contributors, feel free to suggest missing feature or any bug on [GitHub](https://github.com/domarm-comat/pglive/issues). |
0 commit comments