Skip to content

Commit

Permalink
support rescaling with oob mid. closes #103
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonynorth committed Oct 20, 2023
1 parent 379e717 commit 8b11010
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions R/rescale.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,13 @@ rescale_diverge.scale_numeric_category <- rescale_diverge_not_supported

rescale_breaks <- function(scale, x) {
range <- (scale$limits %||% scale$data)$range
tidyassert::assert(x >= range[1] & x <= range[2])

# use transform if available
trans <- attr(scale$get_breaks, "trans")
if (!is.null(trans)) {
scales::rescale(trans$transform(x), from = trans$transform(range))
# approximate function from breaks
} else {
# approximate function from breaks
breaks <- scale$get_breaks(range)
rescale <- stats::splinefun(breaks, seq.int(0, 1, length.out = length(breaks)))
rescale(x)
Expand Down

0 comments on commit 8b11010

Please sign in to comment.