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

Logarithm axes in plots library #21

Merged
merged 23 commits into from
Jul 29, 2024

Conversation

jamesrswift
Copy link
Collaborator

@jamesrswift jamesrswift commented Jul 26, 2024

(This is a continuation of changes discussed in #3, #15)

As with previously, this is a draft PR, intended to share progress and collaborate on what is a highly sought-after feature.

This implementation adds axis optios {x}-mode that takes "lin" (default) or "log", which changes logic in transform-vec (along with a small refactor). Additionally, a different compute-ticks heuristic is defined and applied, which now places major ticks on powers of axis.base (default: 10), and places n logarithmically scaled minor ticks where n is int(axis.base / ticks.minor-step).

image

@johannes-wolf johannes-wolf self-requested a review July 26, 2024 15:43
@@ -303,6 +303,9 @@
axis.min -= 1; axis.max += 1
}

axis.mode = get-axis-option(name, "mode", "lin")
axis.base = get-axis-option(name, "base", 10)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I imagine this could be useful for other things, like the ticks PR you have at the moment #18

Copy link
Member

Choose a reason for hiding this comment

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

If we merge #18, you could pick the default formatter based on the axis options 👍.
The formatter itself does not know about the axis.

tests/plot/ref/1.png Outdated Show resolved Hide resolved
tests/plot/marks/test.typ Outdated Show resolved Hide resolved
@jamesrswift jamesrswift marked this pull request as ready for review July 29, 2024 09:39
Copy link
Member

@johannes-wolf johannes-wolf left a comment

Choose a reason for hiding this comment

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

LGTM.

@johannes-wolf johannes-wolf merged commit f150f9f into cetz-package:master Jul 29, 2024
1 check failed
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.

2 participants