Skip to content
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

Add logarithmic plot axes #29

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

mkalte666
Copy link
Contributor

@mkalte666 mkalte666 commented Jul 18, 2024

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

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

  • Arbitrary bases for the log plotting. The mark generator already can handle them i think. Wouldn't be too hard.
  • Test images and plot marks and the likes
  • A few more robustness additions are needed for programmatic interactions with the plot.
  • More documentation, especially in Plot::log_axes to explain what is going on and why some things are a bad idea in log plots.

Other work in this direction :

@mkalte666 mkalte666 changed the title Logarithmic plot axes Add logarithmic plot axes Jul 18, 2024
@mkalte666 mkalte666 force-pushed the log_plot branch 2 times, most recently from 6cd8528 to 65c354c Compare December 18, 2024 09:21
@mkalte666 mkalte666 force-pushed the log_plot branch 2 times, most recently from c19e013 to 3c3fd09 Compare January 6, 2025 14:23
@mkalte666
Copy link
Contributor Author

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