Skip to content

Commit

Permalink
fix bug in label_number when scale_cut argument is provided (r-li…
Browse files Browse the repository at this point in the history
  • Loading branch information
Colin Douglas authored and Colin Douglas committed Feb 7, 2024
1 parent 84560bf commit 1dc05ab
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions R/label-number.R
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ scale_cut <- function(x, breaks, scale = 1, accuracy = NULL, suffix = "") {
if (any(bad_break)) {
# If the break below result in a perfect cut, prefer it
lower_break <- breaks[match(break_suffix[bad_break], names(breaks)) - 1]
lower_break[lower_break == 0] <- 1 # Avoid choosing a non-existent break
improved_break <- (x[bad_break] * scale / lower_break) %% 1 == 0
# Unless the break below is a power of 10 change (1.25 is as good as 1250)
power10_break <- log10(breaks[break_suffix[bad_break]] / lower_break) %% 1 == 0
Expand Down

0 comments on commit 1dc05ab

Please sign in to comment.