@@ -653,11 +653,14 @@ Guides <- ggproto(
653
653
height = heightDetails(grobs [[i ]]))
654
654
)
655
655
}
656
-
657
- spacing <- convertWidth(theme $ legend.spacing.x , " cm" )
656
+ spacing <- theme $ legend.spacing.x
657
+ stretch_spacing <- any(unitType(spacing ) == " null" )
658
+ if (! stretch_spacing ) {
659
+ spacing <- convertWidth(spacing , " cm" )
660
+ }
658
661
heights <- unit(height_cm(lapply(heights , sum )), " cm" )
659
662
660
- if (stretch_x ) {
663
+ if (stretch_x || stretch_spacing ) {
661
664
widths <- redistribute_null_units(widths , spacing , margin , " width" )
662
665
vp_width <- unit(1 , " npc" )
663
666
} else {
@@ -692,10 +695,14 @@ Guides <- ggproto(
692
695
)
693
696
}
694
697
695
- spacing <- convertHeight(theme $ legend.spacing.y , " cm" )
698
+ spacing <- theme $ legend.spacing.y
699
+ stretch_spacing <- any(unitType(spacing ) == " null" )
700
+ if (! stretch_spacing ) {
701
+ spacing <- convertWidth(spacing , " cm" )
702
+ }
696
703
widths <- unit(width_cm(lapply(widths , sum )), " cm" )
697
704
698
- if (stretch_y ) {
705
+ if (stretch_y || stretch_spacing ) {
699
706
heights <- redistribute_null_units(heights , spacing , margin , " height" )
700
707
vp_height <- unit(1 , " npc" )
701
708
} else {
0 commit comments