@@ -499,33 +499,39 @@ build_strip <- function(label_df, labeller, theme, horizontal) {
499
499
# Create matrix of labels
500
500
labels <- lapply(labeller(label_df ), cbind )
501
501
labels <- do.call(" cbind" , labels )
502
+ ncol <- ncol(labels )
503
+ nrow <- nrow(labels )
502
504
503
505
if (horizontal ) {
504
- grobs_top <- apply(labels , c(1 , 2 ), element_render , theme = theme ,
505
- element = " strip.text.x.top" , margin_x = TRUE ,
506
- margin_y = TRUE )
507
- grobs_top <- assemble_strips(grobs_top , theme , horizontal , clip = " on" )
506
+ grobs_top <- lapply(labels , element_render , theme = theme ,
507
+ element = " strip.text.x.top" , margin_x = TRUE ,
508
+ margin_y = TRUE )
509
+ grobs_top <- assemble_strips(matrix (grobs_top , ncol = ncol , nrow = nrow ),
510
+ theme , horizontal , clip = " on" )
508
511
509
- grobs_bottom <- apply(labels , c(1 , 2 ), element_render , theme = theme ,
510
- element = " strip.text.x.bottom" , margin_x = TRUE ,
511
- margin_y = TRUE )
512
- grobs_bottom <- assemble_strips(grobs_bottom , theme , horizontal , clip = " on" )
512
+ grobs_bottom <- lapply(labels , element_render , theme = theme ,
513
+ element = " strip.text.x.bottom" , margin_x = TRUE ,
514
+ margin_y = TRUE )
515
+ grobs_bottom <- assemble_strips(matrix (grobs_bottom , ncol = ncol , nrow = nrow ),
516
+ theme , horizontal , clip = " on" )
513
517
514
518
list (
515
519
top = grobs_top ,
516
520
bottom = grobs_bottom
517
521
)
518
522
} else {
519
- grobs_left <- apply(labels , c(1 , 2 ), element_render , theme = theme ,
520
- element = " strip.text.y.left" , margin_x = TRUE ,
521
- margin_y = TRUE )
522
- grobs_left <- assemble_strips(grobs_left , theme , horizontal , clip = " on" )
523
-
524
- grobs_right <- apply(labels [, rev(seq_len(ncol(labels ))), drop = FALSE ],
525
- c(1 , 2 ), element_render , theme = theme ,
526
- element = " strip.text.y.right" , margin_x = TRUE ,
523
+ grobs_left <- lapply(labels , element_render , theme = theme ,
524
+ element = " strip.text.y.left" , margin_x = TRUE ,
527
525
margin_y = TRUE )
528
- grobs_right <- assemble_strips(grobs_right , theme , horizontal , clip = " on" )
526
+ grobs_left <- assemble_strips(matrix (grobs_left , ncol = ncol , nrow = nrow ),
527
+ theme , horizontal , clip = " on" )
528
+
529
+ grobs_right <- lapply(labels [, rev(seq_len(ncol(labels ))), drop = FALSE ],
530
+ element_render , theme = theme ,
531
+ element = " strip.text.y.right" , margin_x = TRUE ,
532
+ margin_y = TRUE )
533
+ grobs_right <- assemble_strips(matrix (grobs_right , ncol = ncol , nrow = nrow ),
534
+ theme , horizontal , clip = " on" )
529
535
530
536
list (
531
537
left = grobs_left ,
0 commit comments