GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor z-order to ensure axes are on top by almarklein · Pull Request #906 · fastplotlib/fastplotlib

Conversation

@almarklein

@almarklein almarklein commented Oct 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

Closes #903, closes #839.

  • Graphics are no longer offset in depth, because the depth may actually mean something.
  • Except ImageGraphics, they are now pushed back (older further away).
  • Lines, points, and axes use depth_campare="<=" so that for objects at the same depth, the render order determines which one is on top.
  • Set render_queue of axes so they are rendered later than all the other objects.

This should make it that axes and graphics interact as expected in both 3D and 2D scenes. Note that in a 2D view (panzoom controller), if a scatter graphic has data that is nonzero for z, it can indeed cover the axes, but this is expected.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
almarklein added 3 commits October 2, 2025 12:03
@almarklein
Only auto-offset images, and push back instead of forward
cd53903
@almarklein
remove unnecessary use of offset
1bfc19f
@almarklein
restore thin line
d049e36
@almarklein
almarklein requested review from clewis7 and kushalkolar as code owners October 2, 2025 10:40
@almarklein

almarklein commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator Author

One thing that makes this tricky is that although a lot of examples / use-cases are 2D, it's hard to determine reliably when we can assume the scene to be 2D. Therefore I went with an approach that more or less assumes 3D but also works well in 2D.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar

kushalkolar commented Oct 2, 2025

Copy link
Copy Markdown
Member

Older images pushed back, so this means if I add a new image it will appear on top of the existing ones? This is desired and most intuitive, and is similar with other plotting libs.

If I add a like and then scatter points, these points will appear on top of the line?

Usually the scene is 3D if the camera.fov > 50

Btw there was this related ideas before: #839

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@almarklein

almarklein commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator Author

if I add a new image it will appear on top of the existing ones?

Exactly. And yet the top image will still be below the points, lines, and axes.

If I add a like and then scatter points, these points will appear on top of the line?

Yes. But here it's a bit more tricky, since (assuming the data is 2D) they are both at z=0, and depth-fighting may be a thing.

There are a few reasons why depth-fighting should be unlikely:

  • The depth range for ortho projection is usually favorable, so we have plenty of precision in the depth buffer.
  • The use of depth_compare = '<=' avoids depth-fighting for two objects at exactly the same depth.

For reference, other measures we can take for depth fighting:

  • Use the invariant keyword for the position in the vertex shader (in PyGfx), which reduces differences due to float roundoff errors as a cause for depth-fighting.
  • Use depth offset, e.g. assign an increasing depth offset to the graphics, in the order they were added.

Usually the scene is 3D if the camera.fov > 50

Usually ... but it's perfectly sensible for sciency 3D data to be rendered using orthographic projection. Whether pan-zoom is used (and looking down z) would be a more appropriate signal. In any case, I really like the idea to create the scene in a way that works for both 2D and 3D cases, so users can switch and all keeps making sense. I think we can make that work.

Btw there was this related ideas before: #839

In the comment in #839 I still assumed the scene was always 2d :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

almarklein added 2 commits October 2, 2025 15:54
@almarklein
restore gridplot
c9541b3
@almarklein
new screenshots
fe924c3
@github-actions

github-actions Bot commented Oct 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

📚 Docs preview built and uploaded! https://www.fastplotlib.org/ver/z-order

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

almarklein added 2 commits October 3, 2025 10:02
@almarklein
add examples
23166b5
@almarklein
update examples again?
8f8a292
@almarklein

almarklein commented Oct 3, 2025

Copy link
Copy Markdown
Collaborator Author

So the release tests are know to fail - we need a new release of PyGfx.

But the other tests keep failing with:

image

I had a look at the diffs, and it looks like cases where previously the data was over the axes, and now it's under 👌

I tried to update the reference images by downloading them from the screenshots action, and replacing them. I am a little confused about the "screenshots-" vs "screenshots-imgui" artifacts, which both seem to contain the same screenshots?

I think I tried both, but to no avail...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Oct 9, 2025
Example for depth_compare pygfx/pygfx#1213
Closed
@kushalkolar

kushalkolar commented Oct 9, 2025

Copy link
Copy Markdown
Member

Lines, points, and axes use depth_campare="<=" so that for objects at the same depth, the render order determines which one is on top.

Can you explain this a bit? I also made a issue on pygfx to understand depth_compare better so maybe I'll wait for that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

kushalkolar
kushalkolar requested changes Oct 9, 2025
View reviewed changes

@kushalkolar kushalkolar left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

very nice, few comments 😄

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread examples/screenshots/nb-lines-data.png Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/screenshots/line_collection_slicing.png Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread examples/screenshots/scatter_colorslice_iris.png Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/_axes.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/graphics/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/layouts/_plot_area.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread fastplotlib/legends/legend.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

almarklein added 2 commits October 9, 2025 09:08
@almarklein
remove screenshots added in wrong plance
ef7d6ce
@almarklein
better blending for iris scatter example
6f13019
@almarklein

almarklein commented Oct 9, 2025

Copy link
Copy Markdown
Collaborator Author

Lines, points, and axes use depth_campare="<=" so that for objects at the same depth, the render order determines which one is on top.

Can you explain this a bit? I also made a issue on pygfx to understand depth_compare better so maybe I'll wait for that.

See pygfx/pygfx#1213 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@kushalkolar kushalkolar mentioned this pull request Oct 9, 2025
Adjust for PyGfx's new ticks #910
Merged
kushalkolar
kushalkolar approved these changes Oct 9, 2025
View reviewed changes
@kushalkolar
kushalkolar merged commit e5a818a into main Oct 10, 2025
@kushalkolar
kushalkolar deleted the z-order branch October 10, 2025 23:31
@kushalkolar kushalkolar mentioned this pull request Oct 19, 2025
New screenshots :D #919
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kushalkolar kushalkolar kushalkolar approved these changes
@clewis7 clewis7 Awaiting requested review from clewis7 clewis7 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Ensure axes are on top with orthographic projections Dynamically place axes on camera near clipping plane

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@almarklein @kushalkolar
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.