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

compose_trans does not work where "reverse" is last #393

Closed
davidhodge931 opened this issue Jul 22, 2023 · 2 comments
Closed

compose_trans does not work where "reverse" is last #393

davidhodge931 opened this issue Jul 22, 2023 · 2 comments

Comments

@davidhodge931
Copy link

library(scales)
#> Warning: package 'scales' was built under R version 4.3.1
demo_continuous(10^c(-2:4), trans = c("reverse", "log10"))
#> scale_x_continuous(trans = c("reverse", "log10"))
#> Error in `compose_trans()`:
#> ! Sequence of transformations yields invalid domain
#> Backtrace:
#>     ▆
#>  1. └─scales::demo_continuous(10^c(-2:4), trans = c("reverse", "log10"))
#>  2.   └─scales:::demo_ggplot(x, "scale_x_continuous", ...)
#>  3.     └─ggplot2 (local) scale(NULL, ...)
#>  4.       └─ggplot2::continuous_scale(...)
#>  5.         └─scales::as.trans(trans)
#>  6.           └─scales::compose_trans(!!!x)
#>  7.             └─rlang::abort("Sequence of transformations yields invalid domain")

Created on 2023-07-22 with reprex v2.0.2

@davidhodge931 davidhodge931 changed the title composed trans: multiple trans does not work where "reverse" is last composed trans does not work where "reverse" is last Jul 22, 2023
@davidhodge931 davidhodge931 changed the title composed trans does not work where "reverse" is last compose_trans does not work where "reverse" is last Jul 22, 2023
@teunbrand
Copy link
Contributor

This behaviour makes sense because the reverse operation transforms the data by multiplying by -1 and you cannot take the log of negative numbers. The error that the domain has become invalid is appropriate I think.

@davidhodge931
Copy link
Author

davidhodge931 commented Jul 22, 2023

Maybe a sentence in help to tell people?

I'd guess most people would have no idea that the data is transformed by -1 when the scale is reversed

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

No branches or pull requests

2 participants