-
Notifications
You must be signed in to change notification settings - Fork 6
Migrate from MatPlotLib to PyQtGraph to plot data #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new PyQtGraph canvas component to plot data in real-time, replacing matplotlib for improved performance in real-time logging. Key changes include:
- Adding the PyQtGraphViewerCanvas class with plotting, animation, and annotation functionality.
- Enhancing color_palette by enabling it to be used as a callable to retrieve colors.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py | New canvas class using PyQtGraph with animation and annotation. |
robot_log_visualizer/plotter/color_palette.py | Added a call method to retrieve colors via a callable interface. |
Comments suppressed due to low confidence (1)
robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py:3
- Duplicate import of 'pyqtgraph' detected. Please remove the redundant import statement to keep the code clean and avoid potential confusion.
import pyqtgraph as pg
I guess we need to add robot-log-visualizer/setup.cfg Line 42 in 1a61360
|
Yes! In the future, we can also move to the toml configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to add
pyqtgraph
to the dependencies in?robot-log-visualizer/setup.cfg
Line 42 in 1a61360
install_requires =
Sure! Done with d3ef505
For now in 1772740 i substituted the MaplotlibViewerCanvas with the PyQtGraphViewerCanvas, but with could think of a logic that allows the user to choose one or another. |
1 similar comment
This comment was marked as duplicate.
This comment was marked as duplicate.
Co-authored-by: Copilot <[email protected]>
We can try to work on this and see if we can merge by few days |
I noticed that while clicking on the point in the dataset just the label is shown and not the circle |
@traversaro when this Will be merge (hopefully) we need to add a new dependency in the superbuild. Do you think Is problematic? How can we handle this? |
It seems available in conda-forge https://anaconda.org/conda-forge/pyqtgraph and apt https://repology.org/project/python:pyqtgraph/versions, so I think we are good to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR replaces the Matplotlib-based plot canvas with a PyQtGraph implementation to speed up rendering and enable real-time logging, and updates the UI to use the new viewer.
- Adds
PyQtGraphViewerCanvas
for interactive, animated time-series plotting. - Removes the old
MatplotlibViewerCanvas
. - Updates dependencies and UI code to wire in the new canvas and add a space-bar play/pause toggle.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
setup.cfg | Added pyqtgraph to install requirements |
robot_log_visualizer/ui/plot_item.py | Swapped out MatplotlibViewerCanvas for PyQtGraphViewerCanvas |
robot_log_visualizer/ui/gui.py | Added space-bar handler in keyPressEvent to toggle play/pause |
robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py | Introduced new PyQtGraphViewerCanvas class |
robot_log_visualizer/plotter/matplotlib_viewer_canvas.py | Removed legacy Matplotlib-based canvas |
robot_log_visualizer/plotter/color_palette.py | Added __call__ method to ColorPalette |
Comments suppressed due to low confidence (1)
robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py:71
- Add unit or integration tests for
PyQtGraphViewerCanvas
(e.g.,update_plots
, mouse‐click annotation) to ensure new plotting behaviors are covered and regressions are caught.
def update_plots(self, paths: Sequence[Path], legends: Sequence[Legend]) -> None:
@@ -48,6 +48,7 @@ install_requires = | |||
pyqtconsole | |||
matplotlib | |||
h5py | |||
pyqtgraph |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider pinning the pyqtgraph
dependency to a specific version range to avoid unintentional breakage from upstream API changes.
pyqtgraph | |
pyqtgraph >=0.12.0, <0.13.0 |
Copilot uses AI. Check for mistakes.
@@ -308,6 +308,15 @@ def keyPressEvent(self, event): | |||
|
|||
self.ui.timeSlider.setValue(new_index) | |||
self.slider_pressed = False | |||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After handling Left/Right arrows and Space, add a super().keyPressEvent(event)
fallback so that other key events continue to behave as expected.
Copilot uses AI. Check for mistakes.
This PR introduces the use of
PyQtGraph
to plot the data. Ideally, this can be used in place ofmatplotlib
for faster execution and might be used for real-time logging, see #80.New functionality:
robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py
: Added a new classPyQtGraphViewerCanvas
to visualize data with PyQtGraph. This class includes methods for initializing the canvas, updating plots, handling mouse clicks for annotations, and controlling animation.Enhancements to existing functionality:
robot_log_visualizer/plotter/color_palette.py
: Added a__call__
method to theColorPalette
class, allowing it to be used as a callable for retrieving colors by index.