diff --git a/NEWS.md b/NEWS.md index 6510487165..b1891e93cf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -90,6 +90,8 @@ * `geom_contour()` now accepts a function in the `breaks` argument (@eliocamp, #4652). +* VISUAL CHANGE: `scale_*_viridis_b()` now uses the full range of the viridis scales (@gregleleu, #4737) + * Updated documentation for `geom_contour()` to correctly reflect argument precedence between `bins` and `binwidth`. (@eliocamp, #4651) diff --git a/R/scale-viridis.r b/R/scale-viridis.r index 570704a41a..fdbeaaebf9 100644 --- a/R/scale-viridis.r +++ b/R/scale-viridis.r @@ -124,14 +124,14 @@ scale_colour_viridis_b <- function(..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "colour") { + pal <- binned_pal( + viridis_pal(alpha, begin, end, direction, option) + ) + binned_scale( aesthetics, "viridis_b", - gradient_n_pal( - viridis_pal(alpha, begin, end, direction, option)(6), - values, - space - ), + pal, na.value = na.value, guide = guide, ... @@ -144,14 +144,14 @@ scale_fill_viridis_b <- function(..., alpha = 1, begin = 0, end = 1, direction = 1, option = "D", values = NULL, space = "Lab", na.value = "grey50", guide = "coloursteps", aesthetics = "fill") { + pal <- binned_pal( + viridis_pal(alpha, begin, end, direction, option) + ) + binned_scale( aesthetics, "viridis_b", - gradient_n_pal( - viridis_pal(alpha, begin, end, direction, option)(6), - values, - space - ), + pal, na.value = na.value, guide = guide, ...