@@ -250,11 +250,18 @@ CoordRadial <- ggproto("CoordRadial", Coord,
250
250
names(gdefs ) <- aesthetics
251
251
252
252
# Train theta guide
253
- for (t in intersect(c(" theta" , " theta.sec" ), aesthetics [! empty ])) {
254
- gdefs [[t ]] <- guides [[t ]]$ train(gdefs [[t ]], panel_params [[t ]])
255
- gdefs [[t ]] <- guides [[t ]]$ transform(gdefs [[t ]], self , panel_params )
256
- gdefs [[t ]] <- guides [[t ]]$ get_layer_key(gdefs [[t ]], layers )
257
- }
253
+ t <- intersect(c(" theta" , " theta.sec" ), aesthetics [! empty ])
254
+ gdefs [t ] <- Map(
255
+ function (guide , guide_param , scale ) {
256
+ guide_param $ theme_suffix <- " theta"
257
+ guide_param <- guide $ train(guide_param , scale )
258
+ guide_param <- guide $ transform(guide_param , self , panel_params )
259
+ guide_param <- guide $ get_layer_key(guide_param , layers )
260
+ },
261
+ guide = guides [t ],
262
+ guide_param = gdefs [t ],
263
+ scale = panel_params [t ]
264
+ )
258
265
259
266
if (! isFALSE(self $ r_axis_inside )) {
260
267
# For radial axis, we need to pretend that rotation starts at 0 and
@@ -269,17 +276,18 @@ CoordRadial <- ggproto("CoordRadial", Coord,
269
276
temp <- modify_list(panel_params , mod )
270
277
271
278
# Train radial guide
272
- for (r in intersect(c(" r" , " r.sec" ), aesthetics [! empty ])) {
273
- gdefs [[r ]] <- guides [[r ]]$ train(gdefs [[r ]], panel_params [[r ]])
274
- gdefs [[r ]] <- guides [[r ]]$ transform(gdefs [[r ]], self , temp ) # Use temp
275
- gdefs [[r ]] <- guides [[r ]]$ get_layer_key(gdefs [[r ]], layers )
276
- }
277
-
278
- # Set theme suffixes
279
- gdefs $ theta $ theme_suffix <- " theta"
280
- gdefs $ theta.sec $ theme_suffix <- " theta"
281
- gdefs $ r $ theme_suffix <- " r"
282
- gdefs $ r.sec $ theme_suffix <- " r"
279
+ r <- intersect(c(" r" , " r.sec" ), aesthetics [! empty ])
280
+ gdefs [r ] <- Map(
281
+ function (guide , guide_param , scale ) {
282
+ guide_param $ theme_suffix <- " r"
283
+ guide_param <- guide $ train(guide_param , scale )
284
+ guide_param <- guide $ transform(guide_param , self , temp )
285
+ guide_param <- guide $ get_layer_key(guide_param , layers )
286
+ },
287
+ guide = guides [r ],
288
+ guide_param = gdefs [r ],
289
+ scale = panel_params [r ]
290
+ )
283
291
284
292
panel_params $ guides $ update_params(gdefs )
285
293
panel_params
0 commit comments