Skip to content

Error from facet_wrap(strip.position = "bottom") + theme_void() #3045

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

Closed
heavywatal opened this issue Dec 23, 2018 · 2 comments · Fixed by #3049
Closed

Error from facet_wrap(strip.position = "bottom") + theme_void() #3045

heavywatal opened this issue Dec 23, 2018 · 2 comments · Fixed by #3049

Comments

@heavywatal
Copy link

heavywatal commented Dec 23, 2018

  • OK: facet_wrap(~cyl, ncol = 2L, strip.position = "bottom") + theme_grey()
  • NG: facet_wrap(~cyl, ncol = 2L, strip.position = "bottom") + theme_void()
  • OK: facet_wrap(~cyl, ncol = 2L, strip.position = "left") + theme_void()
  • OK: facet_wrap(~cyl, ncol = NULL, strip.position = "bottom") + theme_void()

It is observed with both release 3.1.0 and master

ggplot(mtcars, aes(disp, mpg)) +
  geom_point() +
  facet_wrap(~cyl, ncol = 2L, strip.position = "bottom") +
  theme_void()
# Error in if (params$strip.position == "bottom" && theme$strip.placement !=  :
#   missing value where TRUE/FALSE needed
# Calls: <Anonymous> ... ggplot_gtable.ggplot_built -> <Anonymous> -> f -> <Anonymous> -> f
@yutannihilation
Copy link
Member

The error occurs here because theme$strip.placement is NULL.

ggplot2/R/facet-wrap.r

Lines 298 to 305 in 7f13dfa

if (params$strip.position == "bottom" &&
theme$strip.placement != "inside" &&
any(!vapply(row_axes, is.zero, logical(1))) &&
!params$free$x) {
warning("Suppressing axis rendering when strip.position = 'bottom' and strip.placement == 'outside'", call. = FALSE)
} else {
axis_mat_x_bottom[row_pos] <- row_axes
}

I think this == and != should be replaced with identical() or wrapped with isTRUE() for safety. But, potentially, this can be counted as one of theme_void()'s problems. c.f. #3039 (comment).

@lock
Copy link

lock bot commented Aug 17, 2019

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/

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants