Skip to content

fix: highlight_edge, highlight_path and highlight_vertex in 3D - #71

Merged
petercorke merged 1 commit into
mainfrom
fix/highlight-3d
Oct 13, 2026
Merged

petercorke merged 1 commit into
mainfrom
fix/highlight-3d

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Highlighting on a 3D graph did not work in 1.0, although highlight_path did in 0.6.5. Found while checking that plotting is unchanged by the lazy-import change (#70): the 2D figures I rendered before and after were pixel-identical, but 3D highlight_path raised AttributeError: 'FancyArrowPatch' object has no attribute 'do_3d_projection' in both, so it predates that PR.

Cause

  • highlight_edge passed the dimension 2 to _edge_artist whatever the axes were, so on a 3D graph a flat FancyArrowPatch was added to a 3D axes. Adding it succeeded; drawing the figure raised. highlight_path calls it. (This came in with the arrows in feat: plot() draws arrowheads, parallel edges and loops; clearer option names #51; 0.6.5 drew lines.)
  • highlight_vertex used plt.plot(x, y), which on a 3D axes puts the marker at z = 0.

Fix

  • The dimension is that of the axes: 3 if ax.name == "3d". So a 3D graph plotted with force_2d=True is highlighted in 2D.
  • highlight_vertex plots [x], [y], [z] on a 3D axes.

Tests

There were none of highlighting in 3D. tests/test_highlight_3d.py draws the figure (that is where it failed) for both kinds of graph: an edge, a loop, a parallel edge, a path (checked for the artists it adds), a vertex (at its z) and several by name, a force_2d plot; and the 2D vertex marker and edge are unchanged.

771 tests pass, mypy clean. The eight figures I rendered for the comparison: the five 2D ones are pixel-identical to before, the 3D ones that failed now draw.

🤖 Generated with Claude Code

highlight_edge asked for the artist of a 2D axes whatever the axes were, so
on a 3D graph it added a flat FancyArrowPatch to a 3D axes and the figure
could not be drawn (highlight_path therefore failed too, and worked in
0.6.5): the dimension is now that of the axes.  highlight_vertex drew its
marker with plt.plot(x, y), which on a 3D axes is at z = 0: it uses the z of
the vertex.  A 3D graph plotted with force_2d is highlighted in 2D.

There were no tests of highlighting in 3D.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 18 complexity · 0 duplication

Metric Results
Complexity 18
Duplication 0

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 b630230 into main Oct 13, 2026
12 checks passed
@petercorke
petercorke deleted the fix/highlight-3d branch October 13, 2026 02:11
@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.54%. Comparing base (5fea937) to head (0e7e668).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #71      +/-   ##
==========================================
+ Coverage   97.28%   97.54%   +0.26%     
==========================================
  Files           4        4              
  Lines        1581     1586       +5     
==========================================
+ Hits         1538     1547       +9     
+ Misses         43       39       -4     

☔ 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.

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