Skip to content

Commit 5dfccf4

Browse files
committed
handle space_free parameter
1 parent 9292822 commit 5dfccf4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

R/facet_row.R

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ facet_row <- function(facets, scales = "fixed", space = "fixed",
4343
facet <- facet_wrap(facets, nrow = 1, scales = scales, shrink = shrink, labeller = labeller, drop = drop, strip.position = strip.position)
4444
params <- facet$params
4545

46-
params$space_free <- space == 'free'
46+
if ("space" %in% fn_fmls_names(facet_wrap)) {
47+
params$space_free <- list(x = space == 'free', y = FALSE)
48+
} else {
49+
params$space_free <- space == 'free'
50+
}
51+
4752
ggproto(NULL, FacetRow, shrink = shrink, params = params)
4853
}
4954
#' @rdname ggforce-extensions
@@ -53,7 +58,7 @@ facet_row <- function(facets, scales = "fixed", space = "fixed",
5358
FacetRow <- ggproto('FacetRow', FacetWrap,
5459
draw_panels = function(self, panels, layout, x_scales, y_scales, ranges, coord, data, theme, params) {
5560
combined <- ggproto_parent(FacetWrap, self)$draw_panels(panels, layout, x_scales, y_scales, ranges, coord, data, theme, params)
56-
if (params$space_free) {
61+
if (isTRUE(params$space_free)) {
5762
widths <- vapply(layout$PANEL, function(i) diff(ranges[[i]]$x.range), numeric(1))
5863
panel_widths <- unit(widths, "null")
5964
combined$widths[panel_cols(combined)$l] <- panel_widths
@@ -71,7 +76,11 @@ facet_col <- function(facets, scales = "fixed", space = "fixed",
7176
facet <- facet_wrap(facets, ncol = 1, scales = scales, shrink = shrink, labeller = labeller, drop = drop, strip.position = strip.position)
7277
params <- facet$params
7378

74-
params$space_free <- space == 'free'
79+
if ("space" %in% fn_fmls_names(facet_wrap)) {
80+
params$space_free <- list(x = FALSE, y = space == 'free')
81+
} else {
82+
params$space_free <- space == 'free'
83+
}
7584
ggproto(NULL, FacetCol, shrink = shrink, params = params)
7685
}
7786
#' @rdname ggforce-extensions
@@ -81,7 +90,7 @@ facet_col <- function(facets, scales = "fixed", space = "fixed",
8190
FacetCol <- ggproto('FacetCol', FacetWrap,
8291
draw_panels = function(self, panels, layout, x_scales, y_scales, ranges, coord, data, theme, params) {
8392
combined <- ggproto_parent(FacetWrap, self)$draw_panels(panels, layout, x_scales, y_scales, ranges, coord, data, theme, params)
84-
if (params$space_free) {
93+
if (isTRUE(params$space_free)) {
8594
heights <- vapply(layout$PANEL, function(i) diff(ranges[[i]]$y.range), numeric(1))
8695
panel_heights <- unit(heights, "null")
8796
combined$heights[panel_rows(combined)$t] <- panel_heights

0 commit comments

Comments
 (0)