-
Notifications
You must be signed in to change notification settings - Fork 78
Add logarithmic plot axes #29
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
base: main
Are you sure you want to change the base?
Conversation
6cd8528 to
65c354c
Compare
c19e013 to
3c3fd09
Compare
|
I have this PR in productive use again, and will probably force push around quite a bit. Main to-dos for me are the grid spacer and arbitrary log bases. The former works ok enough for now, but there is probably room to make it both efficient and pretty. Arbitrary log bases is trivial - basically replace the vec2b with something option, and use base.powf and log(base) instead of hardcoding log 10. Slightly related: Is there a way to disable the pipelines for now? I'd like to avoid spamming whoever else gets the emails. |
This commit is an initial implementation for adding logarithmic plotting axis. This very much needs more testing! The basic idea is, that everything stays the same, but PlotTransform does the much needed coordinate transformation for us. That is, unfortunatley not all of the story. * In a lot of places, we need estimates of "how many pixels does 1 plot space unit take" and the likes, either for overdraw reduction, or generally to size things. PlotTransform has been modifed for that for now, so this should work. * While the normal grid spacer renders just fine, it will also casually try to generate 100s of thousands of lines for a bigger range log plot. So GridInput has been made aware if there is a log axis present. The default spacer has also been modified to work initially. * All of the PlotBound transformations within PlotTransform need to be aware and handle the log scaling properly. This is done and works well, but its a bit.. icky, for lack of a better word. If someone has a better idea how to handle this, be my guest :D * PlotPoint generation from generator functions has to become aware of logarithmic plotting, otherwise the resolution of the plotted points will suffer. Especially the spacer generation is still kinda WIP; it is messy at best right now. Especially for zooming in, it currently only adds lines on the lower bound due to the way the generator function works right now. I will address this in a follow up commit/--amend (or someone else will).
|
Hi @mkalte666, what is the state of this PR? I would also like to use (semi-)log plots with egui, and this seems the closest effort to getting them supported. I'd be happy to contribute some time to it. |
I am keeping this up to date with releases now and then, as i am using this PR at work. It should (tm) be trivial to rebase at the moment. But try as i might, i have not found the time to clean this up enough to make this mergable. Sorry for that. I dare say you should be fine to use this as-is, but there are some things left to do. Mostly grid/axis tick generator is a big mess right now and the code needs to be more generic on the axis transformation. I also think at some point i should look at API names one more time, to make sure they are consistent with the rest of egui_plot. If you have time to help out feel free; otherwise i still think ill finish this at some point. Just, so much to do etc etc. |
This commit is an initial implementation for adding logarithmic plotting axis.
This very much needs more testing!
The basic idea is, that everything stays the same, but PlotTransform does the much needed coordinate transformation for us.
That is, unfortunatley not all of the story.
Especially the spacer generation is still kinda WIP; it is messy at best right now. Especially for zooming in, it currently only adds it on the lower bound due to the way the generator function works right now.
I will address this in a follow up commit (or someone else will).
Things to consider / to do
Plot::log_axesto explain what is going on and why some things are a bad idea in log plots.Other work in this direction :