How do I derive log breaks where the min and max break cover the range of the data?

How do I derive log breaks where the min and max break cover the range of the data?

In the example below, scales::breaks_log(3) produces a max break that is less than the max of the data. I would like to ensure it is always more

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

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

fake your data being wider ?

pressure <- seq(from=0.0002,
              to=806.0000,by=1)
(pr <- range(pressure))
(l10_pr <- log10(pr))
(l10_pr[1] <- floor(l10_pr[1])-1)
(l10_pr[2] <- ceiling(l10_pr[2])+1)
(fakerange <- 10^l10_pr)
scales::breaks_log(3)(fakerange)
#  0.00001    0.10000 1000.00000
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.