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: could scales::breaks_log have an argument to return breaks that encompass the full range of the data? #391

Open
davidhodge931 opened this issue Jul 20, 2023 · 4 comments
Labels
feature a feature request or enhancement

Comments

@davidhodge931
Copy link

Is it possible for scales::log_breaks to get an argument to where the breaks should cover the full range of the data?

library(tidyverse)
range(pressure$pressure)
#> [1]   0.0002 806.0000
scales::breaks_log(7)(range(pressure$pressure))
#> [1] 1e-04 1e-03 1e-02 1e-01 1e+00 1e+01 1e+02 1e+03
scales::breaks_log(3)(range(pressure$pressure))
#> [1] 1e-04 1e-01 1e+02
scales::breaks_log(1)(range(pressure$pressure))  
#> [1] 1e-04

scales::breaks_pretty(7)(range(pressure$pressure))
#>  [1]   0 100 200 300 400 500 600 700 800 900
scales::breaks_pretty(3)(range(pressure$pressure))
#> [1]    0  200  400  600  800 1000
scales::breaks_pretty(1)(range(pressure$pressure))
#> [1]    0 1000

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

@davidhodge931 davidhodge931 changed the title Feature request: could scales::breaks_log have an argument to cover the full range of the data? Feature request: could scales::breaks_log have an argument to cover the full range of the data? Jul 20, 2023
@teunbrand
Copy link
Contributor

I'm sorry David: I'm afraid I don't fully understand. Can you give an example of how something is not quite behaving as you'd like and what the result should be instead?

@davidhodge931
Copy link
Author

In the example above, the max of the data is 806. If you use scales::breaks_log(3)(range(pressure$pressure)), you get a max of 100. It might be useful if you could specify a bounds argument to ensure that the log breaks always cover the range of the data? If you think it's too hard, feel free to close @teunbrand?

@davidhodge931
Copy link
Author

I'll close this. Seems too difficult and not that necessary on reflection

@davidhodge931
Copy link
Author

davidhodge931 commented Jul 20, 2024

On reflection, this would be super useful if possible.

Example code below demonstrating how breaks_extended has an argument to ensure the breaks encompass the range of the data.

scales::breaks_log does not have this, and this Issue is a request of whether it could have an argument to do this? I.e. return c( 0.0001, 0.1, 100, 1000) in the below breaks_log code.

range(pressure$pressure)
#> [1]   0.0002 806.0000
scales::number(scales::breaks_extended(3)(range(pressure$pressure)), accuracy = 0.0001)
#> [1] "0.0000"   "400.0000" "800.0000"
scales::number(scales::breaks_extended(3, only.loose = TRUE)(range(pressure$pressure)), accuracy = 0.0001)
#> [1] "0.0000"     "500.0000"   "1 000.0000"
scales::number(scales::breaks_log(3)(range(pressure$pressure)), accuracy = 0.0001)
#> [1] "0.0001"   "0.1000"   "100.0000"

Created on 2024-07-21 with reprex v2.1.0

This links to #440 and would be useful for all scales::breaks_* functions.

When this option is triggerred and it falls back to breaks_extended, it should use breaks_extended(..., only.loose = TRUE)
image

@davidhodge931 davidhodge931 changed the title Feature request: could scales::breaks_log have an argument to cover the full range of the data? Feature request: could scales::breaks_log have an argument to return breaks that encompass the full range of the data? Jul 20, 2024
@thomasp85 thomasp85 added the feature a feature request or enhancement label Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants