Skip to content
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

gtsam python gtsam_plot.plot_pose2d patch.Ellipse.__init__() has changed. #1952

Closed
PeterQFR opened this issue Dec 30, 2024 · 5 comments
Closed

Comments

@PeterQFR
Copy link
Contributor

PeterQFR commented Dec 30, 2024

Description

The api for matplotlib.patches.Ellipse().__init__() appears to change. Currently using a version 3.8

Steps to reproduce

  1. Run examples/Pose2ISAM2Example.py with numpy==1.26 and matplotlib==3.8
  2. There iwll be an error
Traceback (most recent call last):
  File "/home/peter-laptop/multiagent/venv/lib/python3.11/site-packages/gtsam/examples/Pose2ISAM2Example.py", line 178, in <module>
    Pose2SLAM_ISAM2_example()
  File "/home/peter-laptop/multiagent/venv/lib/python3.11/site-packages/gtsam/examples/Pose2ISAM2Example.py", line 164, in Pose2SLAM_ISAM2_example
    report_on_progress(graph, current_estimate, i)
  File "/home/peter-laptop/multiagent/venv/lib/python3.11/site-packages/gtsam/examples/Pose2ISAM2Example.py", line 42, in report_on_progress
    gtsam_plot.plot_pose2(0, current_estimate.atPose2(i), 0.5, marginals.marginalCovariance(i))
  File "/home/peter-laptop/multiagent/venv/lib/python3.11/site-packages/gtsam/utils/plot.py", line 279, in plot_pose2
    plot_pose2_on_axes(axes,
  File "/home/peter-laptop/multiagent/venv/lib/python3.11/site-packages/gtsam/utils/plot.py", line 252, in plot_pose2_on_axes
    plot_covariance_ellipse_2d(axes, origin, gPp)
  File "/home/peter-laptop/multiagent/venv/lib/python3.11/site-packages/gtsam/utils/plot.py", line 155, in plot_covariance_ellipse_2d
    e1 = patches.Ellipse(origin,
         ^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Ellipse.__init__() takes 4 positional arguments but 5 were given


Expected behavior

No Error.

This error can be fixed by replacing
gtsam/utils/plot.py Line 156 with a kwarg for angle instead of existing positional arguments. It seems that matplotlib has changed angle to a kwarg.
eg new line 156

e1 = patches.Ellipse(origin, 
                                   np.sqrt(w[0])*2*k,
                                   np.sqrt(W[1])*2*k,
                                   angle=np.rad2deg(angle),
                                   fill=False)

Environment

linux, python,
matplotlib=3.8
numpy=1.26

Additional information

@Dream-t
Copy link

Dream-t commented Jan 3, 2025

I also had the same issue, tried your method and it did work, thanks!

@varunagrawal
Copy link
Collaborator

@PeterQFR are you using the PyPI version? We already fixed this in the latest develop branch. @truher has been working on a nightly python release build in #1906 which you may be interested in.

@PeterQFR
Copy link
Contributor Author

PeterQFR commented Jan 5, 2025

Hi @varunagrawal yes it was the PyPI version. I'll have a look at the nightly.
If you're already fixed this then we can close this issue.

@varunagrawal
Copy link
Collaborator

Thanks for the quick response.

In case the nightly version isn't ready yet, you could always install from source. Takes a bit longer but you'll get lots of cool features including intellisense support in VS Code.

@PeterQFR
Copy link
Contributor Author

PeterQFR commented Jan 5, 2025

@varunagrawal, thanks this is my first time using the python version of gtsam. I have mainly been using the C++. It fills in a nice gap in the python ecosystem, for just providing an object-oriented handling of transformations. I am liking the fact that it is fully featured compared to the cpp libraries and will likely be my go-to for this.

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

No branches or pull requests

3 participants