@@ -356,10 +356,14 @@ FacetGrid <- ggproto("FacetGrid", Facet,
356
356
theme $ panel.spacing.y %|| % theme $ panel.spacing )
357
357
358
358
# Add axes
359
- panel_table <- gtable_add_rows(panel_table , max_height(axes $ x $ top ), 0 )
360
- panel_table <- gtable_add_rows(panel_table , max_height(axes $ x $ bottom ), - 1 )
361
- panel_table <- gtable_add_cols(panel_table , max_width(axes $ y $ left ), 0 )
362
- panel_table <- gtable_add_cols(panel_table , max_width(axes $ y $ right ), - 1 )
359
+ axis_height_top <- max_height(axes $ x $ top )
360
+ axis_height_bottom <- max_height(axes $ x $ bottom )
361
+ axis_width_left <- max_width(axes $ y $ left )
362
+ axis_width_right <- max_width(axes $ y $ right )
363
+ panel_table <- gtable_add_rows(panel_table , axis_height_top , 0 )
364
+ panel_table <- gtable_add_rows(panel_table , axis_height_bottom , - 1 )
365
+ panel_table <- gtable_add_cols(panel_table , axis_width_left , 0 )
366
+ panel_table <- gtable_add_cols(panel_table , axis_width_right , - 1 )
363
367
panel_pos_col <- panel_cols(panel_table )
364
368
panel_pos_rows <- panel_rows(panel_table )
365
369
@@ -377,7 +381,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
377
381
panel_pos_col <- panel_cols(panel_table )
378
382
if (switch_x ) {
379
383
if (! is.null(strips $ x $ bottom )) {
380
- if (inside_x ) {
384
+ if (inside_x || as.numeric( axis_height_bottom ) == 0 ) {
381
385
panel_table <- gtable_add_rows(panel_table , max_height(strips $ x $ bottom ), - 2 )
382
386
panel_table <- gtable_add_grob(panel_table , strips $ x $ bottom , - 2 , panel_pos_col $ l , clip = " on" , name = paste0(" strip-b-" , seq_along(strips $ x $ bottom )), z = 2 )
383
387
} else {
@@ -388,7 +392,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
388
392
}
389
393
} else {
390
394
if (! is.null(strips $ x $ top )) {
391
- if (inside_x ) {
395
+ if (inside_x || as.numeric( axis_height_top ) == 0 ) {
392
396
panel_table <- gtable_add_rows(panel_table , max_height(strips $ x $ top ), 1 )
393
397
panel_table <- gtable_add_grob(panel_table , strips $ x $ top , 2 , panel_pos_col $ l , clip = " on" , name = paste0(" strip-t-" , seq_along(strips $ x $ top )), z = 2 )
394
398
} else {
@@ -401,7 +405,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
401
405
panel_pos_rows <- panel_rows(panel_table )
402
406
if (switch_y ) {
403
407
if (! is.null(strips $ y $ left )) {
404
- if (inside_y ) {
408
+ if (inside_y || as.numeric( axis_width_left ) == 0 ) {
405
409
panel_table <- gtable_add_cols(panel_table , max_width(strips $ y $ left ), 1 )
406
410
panel_table <- gtable_add_grob(panel_table , strips $ y $ left , panel_pos_rows $ t , 2 , clip = " on" , name = paste0(" strip-l-" , seq_along(strips $ y $ left )), z = 2 )
407
411
} else {
@@ -412,7 +416,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
412
416
}
413
417
} else {
414
418
if (! is.null(strips $ y $ right )) {
415
- if (inside_y ) {
419
+ if (inside_y || as.numeric( axis_width_right ) == 0 ) {
416
420
panel_table <- gtable_add_cols(panel_table , max_width(strips $ y $ right ), - 2 )
417
421
panel_table <- gtable_add_grob(panel_table , strips $ y $ right , panel_pos_rows $ t , - 2 , clip = " on" , name = paste0(" strip-r-" , seq_along(strips $ y $ right )), z = 2 )
418
422
} else {
0 commit comments