Skip to content

Commit 48cd5ea

Browse files
committed
use calc_element() to compute panel spacing
1 parent 9292822 commit 48cd5ea

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

R/facet_zoom.R

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,9 @@ FacetZoom <- ggproto('FacetZoom', Facet,
282282
}
283283

284284
if ('full' %in% layout$name && params$split) {
285-
space.x <- theme$panel.spacing.x
286-
if (is.null(space.x)) space.x <- theme$panel.spacing
285+
space.x <- calc_element("panel.spacing.x", theme)
287286
space.x <- unit(5 * as.numeric(convertUnit(space.x, 'cm')), 'cm')
288-
space.y <- theme$panel.spacing.y
289-
if (is.null(space.y)) space.y <- theme$panel.spacing
287+
space.y <- calc_element("panel.spacing.y", theme)
290288
space.y <- unit(5 * as.numeric(convertUnit(space.y, 'cm')), 'cm')
291289
final <- gtable_add_cols(panelGrobs[[3]], space.x)
292290
final <- cbind(final, panelGrobs[[1]], size = 'first')
@@ -320,8 +318,7 @@ FacetZoom <- ggproto('FacetZoom', Facet,
320318
final$widths <- widths
321319
} else {
322320
if (params$horizontal) {
323-
space <- theme$panel.spacing.x
324-
if (is.null(space)) space <- theme$panel.spacing
321+
space <- calc_element("panel.spacing.x", theme)
325322
space <- unit(5 * as.numeric(convertUnit(space, 'cm')), 'cm')
326323
heights <- unit.c(
327324
unit(max_height(list(axes$x[[1]]$top, axes$x[[2]]$top)), 'cm'),
@@ -335,8 +332,7 @@ FacetZoom <- ggproto('FacetZoom', Facet,
335332
final <- gtable_add_grob(final, indicator_h, 2, 3, 2, 5, z = -Inf,
336333
name = 'zoom-indicator')
337334
} else {
338-
space <- theme$panel.spacing.y
339-
if (is.null(space)) space <- theme$panel.spacing
335+
space <- calc_element("panel.spacing.y", theme)
340336
space <- unit(5 * as.numeric(convertUnit(space, 'cm')), 'cm')
341337
widths <- unit.c(
342338
unit(max_width(list(axes$y[[1]]$left, axes$y[[2]]$left)), 'cm'),

0 commit comments

Comments
 (0)