Skip to content

feat(plot): view="xy", "xz" or "yz" starts a PyPlot plot in an axis-aligned view of a plane - #879

Merged
petercorke merged 1 commit into
mainfrom
feat/plot-view
Oct 21, 2026
Merged

petercorke merged 1 commit into
mainfrom
feat/plot-view

Conversation

@petercorke

Copy link
Copy Markdown
Owner

view="xy", "xz" or "yz" starts a PyPlot plot in an axis-aligned, orthographic view of a plane, the first axis to the right and the second up. For plot() and for teach().

robot.plot(q, view="xz")      # a side view
robot.teach(q, view="xy")     # a plan view, with the sliders
  • PyPlot.launch(view=), robot.plot(view=) and robot.teach(view=). It sets the starting view with view_init; nothing locks it, so the plot can be dragged to any other view, and a trajectory does not reset it. None (default) is the usual three-dimensional view. Names are case-insensitive.
  • With plot(env=...) (feat(plot): plot(env=) adds a robot to an earlier scene in a pose of its own, plot(ax=) draws on given axes, and color= sets the color #873) it sets the view of the scene that is added to.
  • A bad name raises ValueError listing the choices, before a figure is made. A backend that cannot set a view (PyPlot2, Swift) raises ValueError saying so.
  • Helpers plane_view(name) and set_plane_view(ax, name) in tools/plot.py. roll is not passed (all the views use zero, the default), since roll needs Matplotlib 3.6 and the minimum version is not pinned.
  • Tests (tests/test_plot_view.py, 43): the angles; that each view really has the first axis to the right and the second up, with the third end-on, by projecting the world axes; launch, plot, teach, ax= and env=; the default unchanged; the view surviving a trajectory and a user rotation; and the errors, including that no figure is left behind.

Not done: the axis that is end-on keeps its tick labels, which overlap in the corner of a flat view (cosmetic, Matplotlib's behaviour). Hiding them would be a follow-up.

Changes public behaviour: new argument only; nothing changes without it.

Ran: the full test suite (all pass except the 20 known test_servo_half_turn failures from a stale compiled extension in my worktree) and mypy (clean, 165 files); rendered the three views of a Puma 560 and checked them by eye. Not run: the docs build, and teach on a real display (the tests use Agg).

Written with Claude Code.

🤖 Generated with Claude Code

…ligned view of a plane

PyPlot.launch(), robot.plot() and robot.teach() take view.  It sets the starting view
with view_init and nothing locks it: the plot can still be rotated, and animation does
not reset it.  The first axis of the plane is to the right and the second is up, in
the orthographic projection that PyPlot already uses.  A bad name raises ValueError
before a figure is made, and a backend that cannot set a view (PyPlot2, Swift) says so.
With env= it sets the view of the scene that is added to.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@petercorke
petercorke enabled auto-merge (squash) October 21, 2026 21:34
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 21 high

Alerts:
⚠ 21 issues (≤ 0 issues of at least minor severity)

Results:
21 new issues

Category Results
Security 21 high

View in Codacy

🟢 Metrics 51 complexity · 2 duplication

Metric Results
Complexity 51
Duplication 2

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@petercorke
petercorke merged commit 649b8fb into main Oct 21, 2026
22 of 23 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 21, 2026
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (ee872d7) to head (0f82940).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/roboticstoolbox/robot/BaseRobot.py 0.00% 18 Missing ⚠️
src/roboticstoolbox/tools/plot.py 0.00% 8 Missing ⚠️
src/roboticstoolbox/backends/PyPlot/PyPlot.py 0.00% 4 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #879   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        146     146           
  Lines      17068   17096   +28     
=====================================
- Misses     17068   17096   +28     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@petercorke
petercorke deleted the feat/plot-view branch October 22, 2026 04:37
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.

1 participant