@@ -499,33 +499,39 @@ build_strip <- function(label_df, labeller, theme, horizontal) {
499499 # Create matrix of labels
500500 labels <- lapply(labeller(label_df ), cbind )
501501 labels <- do.call(" cbind" , labels )
502+ ncol <- ncol(labels )
503+ nrow <- nrow(labels )
502504
503505 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" )
508511
509- grobs_bottom <- apply (labels , c( 1 , 2 ) , element_render , theme = theme ,
512+ grobs_bottom <- lapply (labels , element_render , theme = theme ,
510513 element = " strip.text.x.bottom" , margin_x = TRUE ,
511514 margin_y = TRUE )
512- grobs_bottom <- assemble_strips(grobs_bottom , theme , horizontal , clip = " on" )
515+ grobs_bottom <- assemble_strips(matrix (grobs_bottom , ncol = ncol , nrow = nrow ),
516+ theme , horizontal , clip = " on" )
513517
514518 list (
515519 top = grobs_top ,
516520 bottom = grobs_bottom
517521 )
518522 } 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 ,
527525 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" )
529535
530536 list (
531537 left = grobs_left ,
0 commit comments