Skip to content

Commit 1bdf948

Browse files
committed
append layout attribute to layer data
1 parent 1bfb3c9 commit 1bdf948

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

R/layer.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ layer <- function(geom = NULL, stat = NULL,
9898
data = NULL, mapping = NULL,
9999
position = NULL, params = list(),
100100
inherit.aes = TRUE, check.aes = TRUE, check.param = TRUE,
101-
show.legend = NA, key_glyph = NULL, layer_class = Layer) {
101+
show.legend = NA, key_glyph = NULL, layout = NULL, layer_class = Layer) {
102102
call_env <- caller_env()
103103
user_env <- caller_env(2)
104104

@@ -132,7 +132,7 @@ layer <- function(geom = NULL, stat = NULL,
132132
geom_params <- params[intersect(names(params), geom$parameters(TRUE))]
133133
stat_params <- params[intersect(names(params), stat$parameters(TRUE))]
134134

135-
ignore <- c("key_glyph", "name")
135+
ignore <- c("key_glyph", "name", "layout")
136136
all <- c(geom$parameters(TRUE), stat$parameters(TRUE), geom$aesthetics(), position$aesthetics(), ignore)
137137

138138
# Take care of plain patterns provided as aesthetic
@@ -192,7 +192,8 @@ layer <- function(geom = NULL, stat = NULL,
192192
position = position,
193193
inherit.aes = inherit.aes,
194194
show.legend = show.legend,
195-
name = params$name
195+
name = params$name,
196+
layout = layout %||% params$layout
196197
)
197198
}
198199

@@ -280,6 +281,7 @@ Layer <- ggproto("Layer", NULL,
280281
} else {
281282
self$computed_mapping <- self$mapping
282283
}
284+
attr(data, "layout") <- self$layout
283285

284286
data
285287
},

0 commit comments

Comments
 (0)