Skip to content

Commit 98f5e12

Browse files
authored
Recognise empty scale with limits = <function> as empty (#5948)
* discrete scale is also empty when limits is a function * add news bullet
1 parent 6298aec commit 98f5e12

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
* New function `get_strip_labels()` to retrieve facet labels (@teunbrand, #4979)
128128
* Fixed bug in `position_dodge2()`'s identification of range overlaps
129129
(@teunbrand, #5938, #4327).
130+
* Fixed bug where empty discrete scales weren't recognised as such
131+
(@teunbrand, #5945).
130132

131133
# ggplot2 3.5.1
132134

R/scale-discrete-.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ ScaleDiscretePosition <- ggproto("ScaleDiscretePosition", ScaleDiscrete,
130130
},
131131

132132
is_empty = function(self) {
133-
is.null(self$range$range) && is.null(self$limits) && is.null(self$range_c$range)
133+
is.null(self$range$range) &&
134+
(is.null(self$limits) || is.function(self$limits)) &&
135+
is.null(self$range_c$range)
134136
},
135137

136138
reset = function(self) {

0 commit comments

Comments
 (0)