Skip to content

Use 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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Use PyQtGraph to plot data #94

wants to merge 9 commits into from

Conversation

Giulero
Copy link

@Giulero Giulero commented Apr 14, 2025

This PR introduces the use of PyQtGraph to plot the data. Ideally, this can be used in place of matplotlib for faster execution and might be used for real-time logging, see #80.

Screenshot from 2025-04-14 17-12-20

New functionality:

Enhancements to existing functionality:

@Giulero Giulero self-assigned this Apr 14, 2025
Copy link

@Copilot Copilot AI left a 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

self.active_paths[path_string] = curve

# Remove plots that are no longer active
paths_to_remove = [p for p in self.active_paths if p.split('/') not in paths]
Copy link
Preview

Copilot AI Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach to determine inactive paths by splitting the stored key and comparing it to the paths input may lead to mismatches. Consider using a consistent representation such as comparing the joined strings (e.g., checking if p is not in ["/".join(path) for path in paths]) to reliably remove curves.

Suggested change
paths_to_remove = [p for p in self.active_paths if p.split('/') not in paths]
active_path_strings = {"/".join(path) for path in paths}
paths_to_remove = [p for p in self.active_paths if p not in active_path_strings]

Copilot uses AI. Check for mistakes.

@traversaro
Copy link
Contributor

I guess we need to add pyqtgraph to the dependencies in

install_requires =
?

@GiulioRomualdi
Copy link
Member

I guess we need to add pyqtgraph to the dependencies in

install_requires =
?

Yes! In the future, we can also move to the toml configuration

Copy link
Author

@Giulero Giulero left a 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

install_requires =
?

Sure! Done with d3ef505

@Giulero Giulero marked this pull request as ready for review April 15, 2025 08:31
@Giulero
Copy link
Author

Giulero commented Apr 15, 2025

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
@Giulero

This comment was marked as duplicate.

Giulero

This comment was marked as duplicate.

@Giulero Giulero requested a review from Copilot April 15, 2025 08:33
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • setup.cfg: Language not supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants