Skip to content

Commit d4fc00c

Browse files
committed
Suppress guide for NULL breaks in non-position scales (Fixed #579).
1 parent 1df1e82 commit d4fc00c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

R/scale-.r

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, break
4444
if (bad_labels) {
4545
stop("Breaks and labels have unequal lengths", call. = FALSE)
4646
}
47+
48+
if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
49+
warning("NULL breaks for non-positional scale is invalid. Guide for this scale is suppressed.")
50+
guide <- "none"
51+
}
4752

4853
trans <- as.trans(trans)
4954
if (!is.null(limits)) {
@@ -125,7 +130,12 @@ discrete_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks
125130
if (bad_labels) {
126131
stop("Breaks and labels have unequal lengths", call. = FALSE)
127132
}
128-
133+
134+
if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
135+
warning("NULL breaks for non-positional scale is invalid. Guide for this scale is suppressed.")
136+
guide <- "none"
137+
}
138+
129139
structure(list(
130140
call = match.call(),
131141

0 commit comments

Comments
 (0)