24
24
# ' and `boundary`. Can also be a function that takes group-wise values as input and returns bin boundaries.
25
25
# ' @param follow.scale Alternatively, the bin edges can be copied from the scale
26
26
# ' breaks, either `"major"` or `"minor"`. Ignored when `"off"`. Note that if
27
- # . the scale's limits are updated by other layers or expansions then its
28
- # . breaks are recomputed and might end up different to the value copied for
29
- # . the bin edges. This is not an issue when the scale uses a fixed breaks
30
- # . vector.
27
+ # ' the scale's limits are updated by other layers or expansions then its
28
+ # ' breaks are recomputed and might end up different to the value copied for
29
+ # ' the bin edges. This is not an issue when the scale uses a fixed breaks
30
+ # ' vector.
31
31
# ' @param closed One of `"right"` or `"left"` indicating whether right
32
32
# ' or left edges of bins are included in the bin.
33
33
# ' @param pad If `TRUE`, adds empty bins at either end of x. This ensures
@@ -64,7 +64,7 @@ stat_bin <- function(mapping = NULL, data = NULL,
64
64
breaks = NULL ,
65
65
closed = c(" right" , " left" ),
66
66
pad = FALSE ,
67
- follow.scale = c( " off" , " minor " , " major " ) ,
67
+ follow.scale = " off" ,
68
68
na.rm = FALSE ,
69
69
keep.zeroes = " all" ,
70
70
orientation = NA ,
@@ -144,15 +144,9 @@ StatBin <- ggproto("StatBin", Stat,
144
144
cli :: cli_abort(" Only one of {.arg boundary} and {.arg center} may be specified in {.fn {snake_class(self)}}." )
145
145
}
146
146
147
- if (! is.null(params $ follow.scale )) {
148
- params $ follow.scale <- match.arg(params $ follow.scale , c(" off" , " minor" , " major" ))
149
- if (params $ follow.scale == " off" ) params $ follow.scale <- NULL
150
- }
151
- if (! is.null(params $ follow.scale ) && ! is.null(params $ breaks )) {
152
- cli :: cli_abort(" Only one of {.arg follow.scale} and {.arg breaks} may be specified in {.fn {snake_class(self)}}." )
153
- }
147
+ params $ follow.scale <- match.arg(params $ follow.scale , c(" off" , " minor" , " major" ))
154
148
155
- if (is.null(params $ breaks ) && is.null(params $ binwidth ) && is.null(params $ bins ) && is.null (params $ follow.scale )) {
149
+ if (is.null(params $ breaks ) && is.null(params $ binwidth ) && is.null(params $ bins ) && (params $ follow.scale == " off " )) {
156
150
cli :: cli_inform(" {.fn {snake_class(self)}} using {.code bins = 30}. Pick better value with {.arg binwidth}." )
157
151
params $ bins <- 30
158
152
}
@@ -166,12 +160,12 @@ StatBin <- ggproto("StatBin", Stat,
166
160
center = NULL , boundary = NULL ,
167
161
closed = c(" right" , " left" ), pad = FALSE ,
168
162
breaks = NULL , flipped_aes = FALSE , keep.zeroes = " all" ,
169
- follow.scale = NULL ,
163
+ follow.scale = " off " ,
170
164
# The following arguments are not used, but must
171
165
# be listed so parameters are computed correctly
172
166
origin = NULL , right = NULL , drop = NULL ) {
173
167
x <- flipped_names(flipped_aes )$ x
174
- if (! is.null( follow.scale ) ) {
168
+ if (follow.scale != " off " ) {
175
169
breaks <- switch (follow.scale ,
176
170
minor = scales [[x ]]$ get_breaks_minor(),
177
171
major = scales [[x ]]$ get_breaks())
0 commit comments