Skip to content

Commit f7ce644

Browse files
committed
1 parent 0e465b0 commit f7ce644

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

R/scale-colour.R

+21-6
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ scale_colour_continuous <- function(..., palette = NULL, aesthetics = "colour",
9090
guide = "colourbar", na.value = "grey50",
9191
type = getOption("ggplot2.continuous.colour")) {
9292

93-
if (!is.null(type) && is.null(palette)) {
93+
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
94+
95+
if (has_old_args || !is.null(type) && is.null(palette)) {
9496
scale <- scale_backward_compatibility(
9597
..., guide = guide, na.value = na.value, scale = type,
9698
aesthetic = "colour", type = "continuous"
@@ -110,7 +112,9 @@ scale_fill_continuous <- function(..., palette = NULL, aesthetics = "fill", guid
110112
na.value = "grey50",
111113
type = getOption("ggplot2.continuous.fill")) {
112114

113-
if (!is.null(type) && is.null(palette)) {
115+
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
116+
117+
if (has_old_args || !is.null(type) && is.null(palette)) {
114118
scale <- scale_backward_compatibility(
115119
..., guide = guide, na.value = na.value, scale = type,
116120
aesthetic = "fill", type = "continuous"
@@ -129,7 +133,10 @@ scale_fill_continuous <- function(..., palette = NULL, aesthetics = "fill", guid
129133
scale_colour_binned <- function(..., palette = NULL, aesthetics = "colour", guide = "coloursteps",
130134
na.value = "grey50",
131135
type = getOption("ggplot2.binned.colour")) {
132-
if (!is.null(type) && is.null(palette)) {
136+
137+
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
138+
139+
if (has_old_args || !is.null(type) && is.null(palette)) {
133140
scale <- scale_backward_compatibility(
134141
..., guide = guide, na.value = na.value, scale = type,
135142
aesthetic = "colour", type = "binned"
@@ -148,7 +155,9 @@ scale_colour_binned <- function(..., palette = NULL, aesthetics = "colour", guid
148155
scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide = "coloursteps",
149156
na.value = "grey50",
150157
type = getOption("ggplot2.binned.fill")) {
151-
if (!is.null(type) && is.null(palette)) {
158+
has_old_args <- any(names(enexprs(...)) %in% c("low", "high"))
159+
160+
if (has_old_args || !is.null(type) && is.null(palette)) {
152161
scale <- scale_backward_compatibility(
153162
..., guide = guide, na.value = na.value, scale = type,
154163
aesthetic = "fill", type = "binned"
@@ -212,7 +221,10 @@ scale_fill_binned <- function(..., palette = NULL, aesthetics = "fill", guide =
212221
#' theme_set(old)
213222
scale_colour_discrete <- function(..., palette = NULL, aesthetics = "colour", na.value = "grey50",
214223
type = getOption("ggplot2.discrete.colour")) {
215-
if (!is.null(type) && is.null(palette)) {
224+
225+
has_old_args <- any(names(enexprs(...)) %in% c("h", "c", "l", "h.start", "direction"))
226+
227+
if (has_old_args || !is.null(type) && is.null(palette)) {
216228
scale <- scale_backward_compatibility(
217229
..., na.value = na.value, scale = type,
218230
aesthetic = "colour", type = "discrete"
@@ -230,7 +242,10 @@ scale_colour_discrete <- function(..., palette = NULL, aesthetics = "colour", na
230242
#' @export
231243
scale_fill_discrete <- function(..., palette = NULL, aesthetics = "fill", na.value = "grey50",
232244
type = getOption("ggplot2.discrete.fill")) {
233-
if (!is.null(type) && is.null(palette)) {
245+
246+
has_old_args <- any(names(enexprs(...)) %in% c("h", "c", "l", "h.start", "direction"))
247+
248+
if (has_old_args || !is.null(type) && is.null(palette)) {
234249
scale <- scale_backward_compatibility(
235250
..., na.value = na.value, scale = type,
236251
aesthetic = "fill", type = "discrete"

0 commit comments

Comments
 (0)