diff --git a/NEWS.md b/NEWS.md index d23c0b8d..18aa4a96 100644 --- a/NEWS.md +++ b/NEWS.md @@ -32,6 +32,9 @@ where the formatting is also better._ - Fixed Issue #545 where xaxs/yaxs were not restored when set by an internal function. (#545 @zeileis) +- Fixed Issue #553 where `facet.args = list(free = TRUE)` lead to an error when used + used without facets (#554 @zeileis) + ### Breaking changes ## v0.6.0 diff --git a/R/facet.R b/R/facet.R index 9183a680..fde5f529 100644 --- a/R/facet.R +++ b/R/facet.R @@ -309,8 +309,8 @@ draw_facet_window = function( if (isTRUE(facet.args[["free"]])) { # First, we need to calculate the plot extent and axes range of each # individual facet. - xfree = split(c(x, xmin, xmax), facet)[[ii]] - yfree = split(c(y, ymin, ymax), facet)[[ii]] + xfree = if (!is.null(facet)) split(c(x, xmin, xmax), facet)[[ii]] else c(x, xmin, xmax) + yfree = if (!is.null(facet)) split(c(y, ymin, ymax), facet)[[ii]] else c(y, ymin, ymax) if (null_xlim) xlim = range(xfree, na.rm = TRUE) if (null_ylim) ylim = range(yfree, na.rm = TRUE) xext = extendrange(xlim, f = 0.04)