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

Feature request: label_log() but for negative numbers #421

Open
teunbrand opened this issue Apr 6, 2024 · 0 comments · May be fixed by #422
Open

Feature request: label_log() but for negative numbers #421

teunbrand opened this issue Apr 6, 2024 · 0 comments · May be fixed by #422

Comments

@teunbrand
Copy link
Contributor

Some distributions are logarithm-like, like inverse hyperbolic sine (asinh) and pseudo-logarithmic transformations, but they can handle negative numbers.
However, label_log() does not handle the labelling very gracefully for these transformations.

library(scales)

demo_continuous(
  c(-100, 100),
  transform = "asinh",
  breaks = c(-100, -10, -1, 0, 1, 10, 100),
  labels = label_log()
)
#> scale_x_continuous(transform = "asinh", breaks = c(-100, -10, 
#>     -1, 0, 1, 10, 100), labels = label_log())
#> Warning in format(log(x, base = base), digits = digits): NaNs produced

Created on 2024-04-06 with reprex v2.1.0

The ask here is to either include an option in label_log() to handle signed numbers or have label_log() handle signed numbers by default. I'm proposing the plot above shows something like the plot below:

library(scales)

demo_continuous(
  c(-100, 100),
  transform = "asinh",
  breaks = c(-100, -10, -1, 0, 1, 10, 100),
  labels = expression(-10^2, -10^1, -10^0, 0, +10^0, +10^1, +10^2)
)
#> scale_x_continuous(transform = "asinh", breaks = c(-100, -10, 
#>     -1, 0, 1, 10, 100), labels = expression(-10^2, -10^1, -10^0, 
#>     0, +10^0, +10^1, +10^2))

Created on 2024-04-06 with reprex v2.1.0

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 a pull request may close this issue.

1 participant