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

For a log scale, the tickFormat function should only be considered for ticks that should be visible #2077

Closed
mbostock opened this issue Jun 9, 2024 · 0 comments · Fixed by #2078
Assignees
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Jun 9, 2024

Log scales are a bit unusual in that all the ticks are drawn independent of the ticks option; instead, the ticks option only controls which ticks are labeled.

untitled - 2024-06-09T164644 913

Plot.plot({x: {type: "log", domain: [1, 4200], ticks: 7}})

untitled - 2024-06-09T164647 801

Plot.plot({x: {type: "log", domain: [1, 4200], ticks: 10}})

untitled - 2024-06-09T164649 511

Plot.plot({x: {type: "log", domain: [1, 4200], ticks: 20}})

This means that if you set the tickFormat option with a log scale, it (for the most part) ignores the ticks option. These three specifications produce equivalent output:

untitled - 2024-06-09T164820 342

Plot.plot({x: {type: "log", domain: [1, 4200], ticks: 7, tickFormat: String}})

untitled - 2024-06-09T164820 342

Plot.plot({x: {type: "log", domain: [1, 4200], ticks: 10, tickFormat: String}})

untitled - 2024-06-09T164820 342

Plot.plot({x: {type: "log", domain: [1, 4200], ticks: 20, tickFormat: String}})

It‘d be cleaner if the ticks option filtered the tick labels, composing with the given tickFormat, rather than baking the filtering into the tick format. That way you could override the tick format without affecting the number of displayed ticks.

@mbostock mbostock added the enhancement New feature or request label Jun 9, 2024
@mbostock mbostock changed the title For a log scale, the tickFormat should only be considered for ticks that should be visible For a log scale, the tickFormat function should only be considered for ticks that should be visible Jun 9, 2024
@mbostock mbostock self-assigned this Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant