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

Fix bug in guide_axis_logticks(negative.small) #6126

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6121.

Briefly, is ensures that the limits it uses to calculate log-breaks are sorted.
Moreover, it picks a better default value for negative.small when the scale maximum is small.

Some examples based on the issue's regex; first showing that it now doesn't error and doesn't render absurd tick marks:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

p <- data.frame(
  "Y_val" = c(0, 1e-6, 1e-5, 1e-4),
  "X_val" = c(10, 20, 30, 40)
) |>
  ggplot(aes(x = X_val, y = Y_val)) + 
  geom_point() +
  scale_y_continuous(transform = pseudo_log_trans(sigma = 1e-7, base = 10))

p + guides(y = "axis_logticks")

Second, showing the plot with a reasonable negative.small argument for this plot:

p + guides(y = guide_axis_logticks(negative.small = 1e-7))

Lastly, showing the plot with an inappropriate negative.small argument (which still doesn't throw an error).

p + guides(y = guide_axis_logticks(negative.small = 1))

Created on 2024-09-30 with reprex v2.1.1

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.

Error when using axis_logticks with pseudo_log transformation
1 participant