@@ -174,6 +174,7 @@ Layer <- ggproto("Layer", NULL,
174
174
# calculated before use
175
175
computed_geom_params = NULL ,
176
176
computed_stat_params = NULL ,
177
+ computed_mapping = NULL ,
177
178
178
179
data = NULL ,
179
180
aes_params = NULL ,
@@ -211,16 +212,18 @@ Layer <- ggproto("Layer", NULL,
211
212
setup_layer = function (self , data , plot ) {
212
213
# For annotation geoms, it is useful to be able to ignore the default aes
213
214
if (isTRUE(self $ inherit.aes )) {
214
- self $ mapping <- defaults(self $ mapping , plot $ mapping )
215
+ self $ computed_mapping <- defaults(self $ mapping , plot $ mapping )
215
216
# defaults() strips class, but it needs to be preserved for now
216
- class(self $ mapping ) <- " uneval"
217
+ class(self $ computed_mapping ) <- " uneval"
218
+ } else {
219
+ self $ computed_mapping <- self $ mapping
217
220
}
218
221
219
222
data
220
223
},
221
224
222
225
compute_aesthetics = function (self , data , plot ) {
223
- aesthetics <- self $ mapping
226
+ aesthetics <- self $ computed_mapping
224
227
225
228
# Drop aesthetics that are set or calculated
226
229
set <- names(aesthetics ) %in% names(self $ aes_params )
@@ -296,7 +299,7 @@ Layer <- ggproto("Layer", NULL,
296
299
data <- rename_aes(data )
297
300
298
301
# Assemble aesthetics from layer, plot and stat mappings
299
- aesthetics <- self $ mapping
302
+ aesthetics <- self $ computed_mapping
300
303
aesthetics <- defaults(aesthetics , self $ stat $ default_aes )
301
304
aesthetics <- compact(aesthetics )
302
305
@@ -362,7 +365,7 @@ Layer <- ggproto("Layer", NULL,
362
365
# Combine aesthetics, defaults, & params
363
366
if (empty(data )) return (data )
364
367
365
- aesthetics <- self $ mapping
368
+ aesthetics <- self $ computed_mapping
366
369
modifiers <- aesthetics [is_scaled_aes(aesthetics ) | is_staged_aes(aesthetics )]
367
370
368
371
self $ geom $ use_defaults(data , self $ aes_params , modifiers )
0 commit comments