Skip to content

Conversation

@CattleProdigy
Copy link
Contributor

By "invert" I mean to change the default direction of the axis. The standard convention for plots is for +X to go to the right and +Y to go up. In some scenarios, particularly working with images or camera coordinates, +Y should point down.

There's already an existing strategy for inverting the Y axis in the PlotTransform struct, since screen coordinates have +Y pointing down and plots conventionally have +Y pointing up. That strategy was expanded upon and made configurable from Plot.

A few questions:

  • I avoided breaking PlotTransform::new by providing PlotTransform::new_with_invert_axis which is a bit cumbersome to write out. Would we rather break the API by just adding a parameter to new?
  • I didn't expect there to be any differences from the test snapshot, but there were several small ones. Most of the changes can't really be seen, though there are a few pixels with apparent differences. I don't know if this is just platform differences. The code changes are simple enough that for the not-inverted case, I don't see how anything really out to change. Assuming these are just platform differences, is the convention to update the screenshots or leave it?

Copy link
Contributor

@bircni bircni left a comment

Choose a reason for hiding this comment

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

could you also add an example to the demo?

@CattleProdigy
Copy link
Contributor Author

could you also add an example to the demo?

Done here: f36888e

Copy link
Contributor

@bircni bircni left a comment

Choose a reason for hiding this comment

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

lgtm

This is useful for working with images or camera coordinates
where conventionally +Y points down.

There's already an existing strategy for inverting the Y axis
in the `PlotTransform` struct, since screen coordinates have +Y
pointing down and plots conventionally have +Y pointing up. That
strategy was expanded and made configurable from `Plot`.
Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

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

Nice; thank you!

@emilk emilk added the include in changelog This change will be included in the changelog label Oct 10, 2025
@emilk emilk merged commit 35fd4f9 into emilk:main Oct 10, 2025
10 of 11 checks passed
michalsustr pushed a commit that referenced this pull request Nov 26, 2025
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

include in changelog This change will be included in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

egui_plot invert y axis

3 participants