Skip to content

Add the ability invert the X and/or Y axis #125

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

CattleProdigy
Copy link

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?

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

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.

egui_plot invert y axis
2 participants