@@ -139,18 +139,22 @@ Facet <- ggproto("Facet", NULL,
139139 free <- params $ free %|| % list (x = FALSE , y = FALSE )
140140 space <- params $ space_free %|| % list (x = FALSE , y = FALSE )
141141
142- if ((free $ x || free $ y ) && ! coord $ is_free()) {
143- cli :: cli_abort(
144- " {.fn {snake_class(self)}} can't use free scales with \\
145- {.fn {snake_class(coord)}}."
146- )
147- }
148-
149142 aspect_ratio <- theme $ aspect.ratio
150143 if (! is.null(aspect_ratio ) && (space $ x || space $ y )) {
151144 cli :: cli_abort(" Free scales cannot be mixed with a fixed aspect ratio." )
152145 }
153146
147+ if (! coord $ is_free()) {
148+ if (space $ x && space $ y ) {
149+ aspect_ratio <- aspect_ratio %|| % coord $ ratio
150+ } else if (free $ x || free $ y ) {
151+ cli :: cli_abort(
152+ " {.fn {snake_class(self)}} can't use free scales with \\
153+ {.fn {snake_class(coord)}}."
154+ )
155+ }
156+ }
157+
154158 table <- self $ init_gtable(
155159 panels , layout , theme , ranges , params ,
156160 aspect_ratio = aspect_ratio %|| % coord $ aspect(ranges [[1 ]])
@@ -219,7 +223,7 @@ Facet <- ggproto("Facet", NULL,
219223 if (space $ y ) {
220224 idx <- layout $ PANEL [layout $ COL == 1 ]
221225 heights <- vapply(idx , function (i ) diff(ranges [[i ]]$ y.range ), numeric (1 ))
222- heights <- unit(heights , " null" )
226+ heights <- unit(heights * abs( aspect_ratio % || % 1 ) , " null" )
223227 }
224228
225229 # Build gtable
0 commit comments