@@ -133,7 +133,7 @@ Geom <- ggproto("Geom",
133
133
# Fill in missing aesthetics with their defaults
134
134
missing_aes <- setdiff(names(default_aes ), names(data ))
135
135
default_aes <- default_aes [missing_aes ]
136
- themed_defaults <- eval_from_theme(default_aes , theme )
136
+ themed_defaults <- eval_from_theme(default_aes , theme , class( self ) )
137
137
default_aes [names(themed_defaults )] <- themed_defaults
138
138
139
139
# Mark staged/scaled defaults as modifier (#6135)
@@ -243,13 +243,33 @@ Geom <- ggproto("Geom",
243
243
# ' @rdname is_tests
244
244
is.geom <- function (x ) inherits(x , " Geom" )
245
245
246
- eval_from_theme <- function (aesthetics , theme ) {
246
+ eval_from_theme <- function (aesthetics , theme , class = NULL ) {
247
247
themed <- is_themed_aes(aesthetics )
248
248
if (! any(themed )) {
249
249
return (aesthetics )
250
250
}
251
- settings <- calc_element(" geom" , theme ) %|| % .default_geom_element
252
- lapply(aesthetics [themed ], eval_tidy , data = settings )
251
+
252
+ element <- calc_element(" geom" , theme ) %|| % .default_geom_element
253
+ class <- setdiff(class , c(" Geom" , " ggproto" , " gg" ))
254
+
255
+ if (length(class ) > 0 ) {
256
+
257
+ # CamelCase to dot.case
258
+ class <- gsub(" ([A-Za-z])([A-Z])([a-z])" , " \\ 1.\\ 2\\ 3" , class )
259
+ class <- gsub(" ([a-z])([A-Z])" , " \\ 1.\\ 2" , class )
260
+ class <- to_lower_ascii(class )
261
+
262
+ class <- class [class %in% names(theme )]
263
+
264
+ # Inherit up to parent geom class
265
+ if (length(class ) > 0 ) {
266
+ for (cls in rev(class )) {
267
+ element <- combine_elements(theme [[cls ]], element )
268
+ }
269
+ }
270
+ }
271
+
272
+ lapply(aesthetics [themed ], eval_tidy , data = element )
253
273
}
254
274
255
275
# ' Graphical units
0 commit comments