Skip to content

Free facets error when a facet contains no data #705

Description

@grantmcdermott

Follow-up to #668 / #669. That fix handles a free facet whose data collapse to a single value, but not a facet that holds no data at all.

Example using a facet facet grid, where one combo is missing, i.e. no car is both 8-cylinder and straight-engined (cyl == 8 & vs == 1).

library(tinyplot)

tinyplot(
  mpg ~ wt, data = mtcars,
  facet = cyl ~ vs,
  facet.args = list(prefix = TRUE, free = TRUE)
)
#> Warning in min(x) : no non-missing arguments to min; returning Inf
#> Warning in max(x) : no non-missing arguments to max; returning -Inf
#> Error in par(usr = fusr[[ii]]) :
#>   invalid value specified for graphical parameter "usr"

The empty panel's range() returns c(Inf, -Inf), which propagates a non-finite extent into par(usr=). The #669 guard only fires on a zero-width extent (diff(xext) == 0), so it doesn't catch this.

(Aside: this isn't specific to grids; it affects missing factor levels too.)

Fixed scales (free = FALSE) are unaffected, as are free facets given explicit xlim/ylim.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions