Skip to content

Commit b0134b1

Browse files
authored
Make sure panels are always set to a positive size (#4081)
* Make sure panels are always set to a positive size * Add fix to wrap and grid as well
1 parent 73256c9 commit b0134b1

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

R/facet-grid-.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ FacetGrid <- ggproto("FacetGrid", Facet,
333333
heights <- vapply(ps, function(i) diff(ranges[[i]]$y.range), numeric(1))
334334
panel_heights <- unit(heights, "null")
335335
} else {
336-
panel_heights <- rep(unit(1 * aspect_ratio, "null"), nrow)
336+
panel_heights <- rep(unit(1 * abs(aspect_ratio), "null"), nrow)
337337
}
338338

339339
panel_table <- gtable_matrix("layout", panel_table,

R/facet-null.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ FacetNull <- ggproto("FacetNull", Facet,
6161
), ncol = 3, byrow = TRUE)
6262
z_matrix <- matrix(c(5, 6, 4, 7, 1, 8, 3, 9, 2), ncol = 3, byrow = TRUE)
6363
grob_widths <- unit.c(grobWidth(axis_v$left), unit(1, "null"), grobWidth(axis_v$right))
64-
grob_heights <- unit.c(grobHeight(axis_h$top), unit(aspect_ratio, "null"), grobHeight(axis_h$bottom))
64+
grob_heights <- unit.c(grobHeight(axis_h$top), unit(abs(aspect_ratio), "null"), grobHeight(axis_h$bottom))
6565
grob_names <- c("spacer", "axis-l", "spacer", "axis-t", "panel", "axis-b", "spacer", "axis-r", "spacer")
6666
grob_clip <- c("off", "off", "off", "off", coord$clip, "off", "off", "off", "off")
6767

R/facet-wrap.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ FacetWrap <- ggproto("FacetWrap", Facet,
269269
empties <- apply(panel_table, c(1,2), function(x) is.zero(x[[1]]))
270270
panel_table <- gtable_matrix("layout", panel_table,
271271
widths = unit(rep(1, ncol), "null"),
272-
heights = unit(rep(aspect_ratio, nrow), "null"), respect = respect, clip = coord$clip, z = matrix(1, ncol = ncol, nrow = nrow))
272+
heights = unit(rep(abs(aspect_ratio), nrow), "null"), respect = respect, clip = coord$clip, z = matrix(1, ncol = ncol, nrow = nrow))
273273
panel_table$layout$name <- paste0('panel-', rep(seq_len(ncol), nrow), '-', rep(seq_len(nrow), each = ncol))
274274

275275
panel_table <- gtable_add_col_space(panel_table,

0 commit comments

Comments
 (0)