-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Strip placement (bottom, outside) and empty slots #2622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
reprex with working example without library(ggplot2)
zzz <- data.frame(gp = c("a","b","c","d","e","f","g"),
c1 = c(1,1,1,1,1,1,1),
c2 = c(1,1,1,1,1,1,1))
# without strip position argument
ggplot(zzz, aes(x = c1, y = c2)) +
facet_wrap(~ gp, scales = "free", nrow = 3) +
geom_point() +
theme(
aspect.ratio = 1,
strip.background = element_blank(),
strip.placement = "outside"
) ggplot(zzz, aes(x = c1, y = c2)) +
facet_wrap(~ gp, scales = "free", nrow = 3, strip.position = "bottom") +
geom_point() +
theme(
aspect.ratio = 1,
strip.background = element_blank(),
strip.placement = "outside"
)
#> Error in vapply(row_axes, is.zero, logical(length(row_axes))): values must be length 2,
#> but FUN(X[[1]]) result is length 1 # works for other positions
ggplot(zzz, aes(x = c1, y = c2)) +
facet_wrap(~ gp, scales = "free", nrow = 3, strip.position = "left") +
geom_point() +
theme(
aspect.ratio = 1,
strip.background = element_blank(),
strip.placement = "outside"
) Created on 2018-05-17 by the reprex package (v0.2.0). |
n.b. also works when total number of facets is divisible by the row number library(ggplot2)
zzz <- data.frame(gp = c("a","b","c","d","e","f"),
c1 = c(1,1,1,1,1,1),
c2 = c(1,1,1,1,1,1))
ggplot(zzz, aes(x = c1, y = c2)) +
facet_wrap(~ gp, scales = "free", nrow = 3, strip.position = "bottom") +
geom_point() +
theme(
aspect.ratio = 1,
strip.background = element_blank(),
strip.placement = "outside"
) Created on 2018-05-17 by the reprex package (v0.2.0). Also, though, with a missing facet that's 2 of 2… zzz <- data.frame(gp = c("a","b","c","d","e"),
c1 = c(1,1,1,1,1),
c2 = c(1,1,1,1,1))
ggplot(zzz, aes(x = c1, y = c2)) +
facet_wrap(~ gp, scales = "free", nrow = 3, strip.position = "bottom") +
geom_point() +
theme(
aspect.ratio = 1,
strip.background = element_blank(),
strip.placement = "outside"
)
#> Warning: Suppressing axis rendering when strip.position = 'bottom' and
#> strip.placement == 'outside' |
I can't say I understand the code in question, but one way or another this line looks suspicious: Line 300 in 4b609fb
There's a similar line a little further down, though I wasn't able to create a crash at that position: Line 307 in 4b609fb
The problem with these lines is the last argument to Reprex to show what I mean: library(grid)
library(ggplot2)
row_axes <- list(zeroGrob(), textGrob("test"))
vapply(row_axes, ggplot2:::is.zero, logical(length(1)))
#> [1] TRUE FALSE
vapply(row_axes, ggplot2:::is.zero, logical(length(row_axes)))
#> Error in vapply(row_axes, ggplot2:::is.zero, logical(length(row_axes))): values must be length 2,
#> but FUN(X[[1]]) result is length 1 Created on 2018-05-17 by the reprex package (v0.2.0). |
I’ll look into it today |
It seems to be a simple matter of me messing up the the vapply call... The reason @clauswilke can't provoke an error on the second instance is that it is not possible to have more than a single unfinished row |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
[issue raised at https://stackoverflow.com/questions/50385053/ggplot2-unexpected-vapply-error]
In some situations, empty slots in a row together with the "bottom" parameter lead to the following error:
"Error in vapply(row_axes, is.zero, logical(length(row_axes))) : values must be length 3, but FUN(X[[1]]) result is length 1"
The text was updated successfully, but these errors were encountered: