Skip to content

Commit

Permalink
Doesn't work, playing with it
Browse files Browse the repository at this point in the history
  • Loading branch information
dlcomeaux committed May 6, 2021
1 parent ebdbb66 commit b07fc89
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions R/colors_continuous.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,36 @@ mid_rescaler2 <- function(mid) {
#' @export
cmap_fill_continuous <- function(palette = "seq_reds",
reverse = FALSE,
discrete = FALSE,
middle = 0,
...) {
if (substr(palette,1,3) == "div") {
ggplot2::scale_fill_gradientn(
colours = cmap_pal_continuous(palette, reverse = reverse)(256),
rescaler = mid_rescaler2(middle),
...
)
if (discrete) {
ggplot2::discrete_scale(
"fill", "cmap_palettes",
palette = cmap_pal_discrete(palette, reverse = reverse),
...
)
} else {
ggplot2::scale_fill_gradientn(
colours = cmap_pal_continuous(palette, reverse = reverse)(256),
rescaler = mid_rescaler2(middle),
...
)
}
} else {
ggplot2::scale_fill_gradientn(
colours = cmap_pal_continuous(palette, reverse = reverse)(256),
...
)
if (discrete) {
ggplot2::discrete_scale(
"fill", "cmap_palettes",
palette = cmap_pal_discrete(palette, reverse = reverse),
...
)
} else {
ggplot2::scale_fill_gradientn(
colours = cmap_pal_continuous(palette, reverse = reverse)(256),
...
)
}
}
}

Expand Down

0 comments on commit b07fc89

Please sign in to comment.