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 10 commits into
base: main
Choose a base branch
from
Open

Use PyQtGraph to plot data #94

wants to merge 10 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

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

This comment was marked as outdated.

@GiulioRomualdi
Copy link
Member

We can try to work on this and see if we can merge by few days

@GiulioRomualdi GiulioRomualdi requested a review from Copilot June 28, 2025 10:40
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 replaces matplotlib with PyQtGraph for plotting data to improve performance and enable real-time logging. Key changes include:

  • Adding the pyqtgraph dependency in setup.cfg.
  • Switching the plotting canvas in PlotItem from the MatplotlibViewerCanvas to the new PyQtGraphViewerCanvas.
  • Introducing a new PyQtGraphViewerCanvas class with support for plotting, annotations, and animation control.
  • Enhancing ColorPalette by adding a call method for color retrieval.

Reviewed Changes

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

Show a summary per file
File Description
setup.cfg Added pyqtgraph dependency
robot_log_visualizer/ui/plot_item.py Updated canvas instantiation to use PyQtGraphViewerCanvas
robot_log_visualizer/ui/gui.py Added key press event handling for play/pause toggle
robot_log_visualizer/plotter/pyqtgraph_viewer_canvas.py Added new class for PyQtGraph based plotting and interaction
robot_log_visualizer/plotter/color_palette.py Introduced call to simplify color lookup functionality

closest_point = (xdata[index], ydata[index])

# If the closest point is within a certain distance, add an annotation
if min_dist < 0.01 * (
Copy link
Preview

Copilot AI Jun 28, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider extracting the magic number 0.01 into a named constant to improve code readability and maintainability.

Suggested change
if min_dist < 0.01 * (
if min_dist < self.ANNOTATION_DISTANCE_THRESHOLD_RATIO * (

Copilot uses AI. Check for mistakes.

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