Skip to content

Commit da08478

Browse files
authored
Revdep 31/10/2025 fix (#6721)
* Fix for formula/call labels * mirror #6690 for position aesthetics * preserve attributes of list-labels * fallback for `StatAlign$finish_layer` * be more thorough with truncating label lists
1 parent 2da2b27 commit da08478

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

R/layer.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,8 @@ normalise_label <- function(label) {
974974
if (obj_is_list(label)) {
975975
# Ensure that each element in the list has length 1
976976
label[lengths(label) == 0] <- ""
977-
label <- lapply(label, `[`, 1)
977+
truncate <- !vapply(label, is.call, logical(1)) # Don't mess with call/formula
978+
label[truncate] <- lapply(label[truncate], `[`, 1)
978979
}
979980
if (is.expression(label)) {
980981
# Classed expressions, when converted to lists, retain their class.

R/position-.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ Position <- ggproto(
102102
#' A data frame with completed layer data
103103
use_defaults = function(self, data, params = list()) {
104104

105+
if (empty(data)) {
106+
return(data)
107+
}
108+
105109
aes <- self$aesthetics()
106110
defaults <- self$default_aes
107111

@@ -113,6 +117,13 @@ Position <- ggproto(
113117
return(data)
114118
}
115119

120+
empty_aes <- names(params)[lengths(params) == 0]
121+
if (length(empty_aes) > 0) {
122+
# The Geom$use_defaults method will already warn about this, we just need
123+
# to ignore this here.
124+
params <- params[setdiff(names(params), empty_aes)]
125+
}
126+
116127
new <- compact(lapply(defaults, eval_tidy, data = data))
117128
new[names(params)] <- params
118129
check_aesthetics(new, nrow(data))

R/stat-align.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ StatAlign <- ggproto(
7777

7878
finish_layer = function(data, params) {
7979
# Silently remove out-of-bounds padding vertices
80-
var <- flipped_names(params$flipped_aes)$x
80+
var <- flipped_names(params$flipped_aes %||% FALSE)$x
8181
remove <- is.na(data[[var]]) & (data$align_padding %||% FALSE)
8282
vec_slice(data, !remove)
8383
}

0 commit comments

Comments
 (0)