Skip to content

Commit

Permalink
Use ggdist::ramp_colours in ggdist > 3.3.1 (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjskay authored Mar 2, 2024
1 parent 238ca81 commit 2717ced
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ build_fbl_layer <- function(object, data = NULL, level = c(80, 95),
}
# Apply ramped fill
if (!is.null(data[["fill_ramp"]])) {
data$fill = mapply(function(color, amount){
(scales::seq_gradient_pal(attr(amount, "from") %||% "white", color))(amount %||% NA)
}, data$fill, data$fill_ramp)
if (utils::packageVersion("ggdist") > "3.3.1") {
data$fill <- ggdist::ramp_colours(data$fill, data$fill_ramp)
} else {
data$fill <- mapply(function(color, amount){
(scales::seq_gradient_pal(attr(amount, "from") %||% "white", color))(amount %||% NA)
}, data$fill, data$fill_ramp)
}
}
ggplot2::draw_key_rect(data, params, size)
}
Expand Down

0 comments on commit 2717ced

Please sign in to comment.