Skip to content

Commit d896cad

Browse files
authored
Don't cast orthogonal guide sizes to cm (#6581)
1 parent d03bf8e commit d896cad

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

R/guides-.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ Guides <- ggproto(
659659
if (!stretch_spacing) {
660660
spacing <- convertWidth(spacing, "cm")
661661
}
662-
heights <- unit(height_cm(lapply(heights, sum)), "cm")
662+
663+
total_height <- max(inject(unit.c(!!!lapply(heights, sum))))
663664

664665
if (stretch_x || stretch_spacing) {
665666
widths <- redistribute_null_units(widths, spacing, margin, "width")
@@ -672,14 +673,14 @@ Guides <- ggproto(
672673
# Set global justification
673674
vp <- viewport(
674675
x = global_xjust, y = global_yjust, just = global_just,
675-
height = max(heights),
676+
height = total_height,
676677
width = vp_width
677678
)
678679

679680
# Initialise gtable as legends in a row
680681
guides <- gtable_row(
681682
name = "guides", grobs = grobs,
682-
widths = widths, height = max(heights),
683+
widths = widths, height = total_height,
683684
vp = vp
684685
)
685686

@@ -701,7 +702,7 @@ Guides <- ggproto(
701702
if (!stretch_spacing) {
702703
spacing <- convertWidth(spacing, "cm")
703704
}
704-
widths <- unit(width_cm(lapply(widths, sum)), "cm")
705+
total_width <- max(inject(unit.c(!!!lapply(widths, sum))))
705706

706707
if (stretch_y || stretch_spacing) {
707708
heights <- redistribute_null_units(heights, spacing, margin, "height")
@@ -715,13 +716,13 @@ Guides <- ggproto(
715716
vp <- viewport(
716717
x = global_xjust, y = global_yjust, just = global_just,
717718
height = vp_height,
718-
width = max(widths)
719+
width = total_width
719720
)
720721

721722
# Initialise gtable as legends in a column
722723
guides <- gtable_col(
723724
name = "guides", grobs = grobs,
724-
width = max(widths), heights = heights,
725+
width = total_width, heights = heights,
725726
vp = vp
726727
)
727728

0 commit comments

Comments
 (0)