Skip to content

Log scale implementation for x and y axis#244

Open
asceenl wants to merge 3 commits into
emilk:mainfrom
asceenl:log_scale
Open

Log scale implementation for x and y axis#244
asceenl wants to merge 3 commits into
emilk:mainfrom
asceenl:log_scale

Conversation

@asceenl
Copy link
Copy Markdown

@asceenl asceenl commented May 26, 2026

This pull request refers to issue #187. It is a working log scale implementation for base 10. There are still some improvements I like, especially when zooming in on the plot. This pull request adds some files and an example on how to use it.

For the implementation I had to fix:

  • The memory system. Right now it is implemented that on switching scales, the plot mode switches to auto bounds. Otherwise invalid bounds would transfer from linear scale (which can be negative) to log scale (which should be strictly positive)
  • Added file for handling the transformation between plot space and data space.
  • The grid which is now dependent on the plot transform
  • Tick label placement (I am not 100% satisfied with this yet). It would help also if we would have a superscript minus sign in Egui (or do I miss something?) Please advise...
  • Zooming and panning also have plot transform dependency
  • Fix for extra margin around the plot with auto bounds (should be multiplicative instead of additive on a log scale)

Untested

  • Inverting the axis
  • Drawing other objects than lines

I hope this helps. Let me know if you have any issues, I am here to fix anything you do not like, but for me this was the most important missing feature of egui_plot.

@github-actions
Copy link
Copy Markdown

View snapshot changes at kitdiff

…formType. Made this type Copy to remove Boxing, boxed_clone and created an enum dispatcher for the AxisTransform Trait. With that, the feature = serde problem is fixed.
@asceenl
Copy link
Copy Markdown
Author

asceenl commented May 27, 2026

Edit: I fixed the problem of feature = serde, and improved the AxisTransform code. It now does not trampoline anymore with make_transform(). This fixes a bug, and improves the general layout of the code.

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