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

log_breaks Not Always Useful #168

Closed
billdenney opened this issue Aug 9, 2018 · 2 comments
Closed

log_breaks Not Always Useful #168

billdenney opened this issue Aug 9, 2018 · 2 comments

Comments

@billdenney
Copy link
Contributor

billdenney commented Aug 9, 2018

This is very similar to #100 but a more specialized case.

The second example below does not provide useful breaks (none show up when plotted). I like the "relevant_breaks" addition in #117, and similar code should be added to log_sub_breaks. If log_sub_breaks cannot find >= (n-2) breaks, then I think we should fall back to extended_breaks which has better guarantees of the number of relevant breaks even if we lose the equidistant log-scale spacing.

library(scales, quietly = TRUE)
(scales::log_breaks(base = exp(1)))(c(2, 2.0001))
#> [1] 1.000000 2.000000 2.718282
(scales::log_breaks(base = exp(1)))(c(2.0001, 2.0002))
#> [1] 2.000000 2.718282
(scales::extended_breaks())(c(2.0001, 2.0002))
#> [1] 2.000100 2.000125 2.000150 2.000175 2.000200

This affects many figures for me, so if possible to make it into 1.0.0, I think that would be selfishly beneficial (#157).

@dpseidel
Copy link
Collaborator

dpseidel commented Aug 9, 2018

1.0.0 is up on CRAN as of this morning so unfortunately any change won't make that, but I'd be happy to review/discuss a PR for the dev version.

You're certainly right, currently the log_breaks code is not designed for very small ranges when even integer multiples of base are not sufficient, but my (perhaps wildly off-base) guess is that it's a fairly rare to need/want to transform data over such a small range, in which case scales::extended_breaks() is already the default for all non-log transformed scales.

@billdenney
Copy link
Contributor Author

billdenney commented Aug 9, 2018

Congratulations on 1.0.0!

My use case is that I often generate many (hundreds to thousands) of figures automatically in both linear and semi-log scales for reports. If I didn't provide the log-scale version, I'd be asked why I don't have it.
While I could add testing for small ranges to all of these figures, it is preferable to have scales do what I'm hoping for (which is to give a usable scale regardless of the input).

PR coming shortly.

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