Skip to content
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

enter_fade()/exit_fade() does not seem to work. #487

Open
jtlandis opened this issue Oct 18, 2023 · 2 comments
Open

enter_fade()/exit_fade() does not seem to work. #487

jtlandis opened this issue Oct 18, 2023 · 2 comments

Comments

@jtlandis
Copy link

library(ggplot2)
library(gganimate)

I think there may be an issue arising from vctrs but I am unsure of the extent. Here is a reprex in which we are trying to replicate an example from the trasition-layers documentation

Some other testing (not shown here), I have confirmed that enter_grow and exit_shrink work which is an interesting note.

anim1 <- ggplot(mtcars, aes(mpg, disp)) +
  geom_point() +
  geom_smooth(colour = 'grey', se = FALSE) +
  geom_smooth(aes(colour = factor(gear))) +
  transition_layers(layer_length = 1, transition_length = 2,
                    from_blank = FALSE) +
  enter_fade() + enter_grow()
anim1
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : span too small.  fewer data values than degrees of freedom.
#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : pseudoinverse used at 14.923
#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : neighborhood radius 4.777
#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : reciprocal condition number 0
#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : There are other near singularities as well. 116.14
#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : Chernobyl! trL>n 5

#> Warning in simpleLoess(y, x, w, span, degree = degree, parametric = parametric,
#> : Chernobyl! trL>n 5
#> Warning in sqrt(sum.squares/one.delta): NaNs produced
#> Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
#> else if (is.data.frame(newdata))
#> as.matrix(model.frame(delete.response(terms(object)), : span too small.  fewer
#> data values than degrees of freedom.
#> Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
#> else if (is.data.frame(newdata))
#> as.matrix(model.frame(delete.response(terms(object)), : pseudoinverse used at
#> 14.923
#> Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
#> else if (is.data.frame(newdata))
#> as.matrix(model.frame(delete.response(terms(object)), : neighborhood radius
#> 4.777
#> Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
#> else if (is.data.frame(newdata))
#> as.matrix(model.frame(delete.response(terms(object)), : reciprocal condition
#> number 0
#> Warning in predLoess(object$y, object$x, newx = if (is.null(newdata)) object$x
#> else if (is.data.frame(newdata))
#> as.matrix(model.frame(delete.response(terms(object)), : There are other near
#> singularities as well. 116.14
#> Warning in stats::qt(level/2 + 0.5, pred$df): NaNs produced
#> Error in `vec_rbind()`:
#> ! Can't combine `..1$fill` <logical> and `..2$fill` <character>.
#> Backtrace:
#>      ▆
#>   1. ├─base::tryCatch(...)
#>   2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>   3. │   ├─base (local) tryCatchOne(...)
#>   4. │   │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>   5. │   └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#>   6. │     └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>   7. │       └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>   8. ├─base::withCallingHandlers(...)
#>   9. ├─base::saveRDS(...)
#>  10. ├─base::do.call(...)
#>  11. ├─base (local) `<fn>`(...)
#>  12. ├─global `<fn>`(input = base::quote("neat-koala_reprex.R"))
#>  13. │ └─rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#>  14. │   └─knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#>  15. │     └─knitr:::process_file(text, output)
#>  16. │       ├─base::withCallingHandlers(...)
#>  17. │       ├─base::withCallingHandlers(...)
#>  18. │       ├─knitr:::process_group(group)
#>  19. │       └─knitr:::process_group.block(group)
#>  20. │         └─knitr:::call_block(x)
#>  21. │           └─knitr:::block_exec(params)
#>  22. │             └─knitr:::eng_r(options)
#>  23. │               ├─knitr:::in_input_dir(...)
#>  24. │               │ └─knitr:::in_dir(input_dir(), expr)
#>  25. │               └─knitr (local) evaluate(...)
#>  26. │                 └─evaluate::evaluate(...)
#>  27. │                   └─evaluate:::evaluate_call(...)
#>  28. │                     ├─evaluate (local) handle(...)
#>  29. │                     │ └─base::try(f, silent = TRUE)
#>  30. │                     │   └─base::tryCatch(...)
#>  31. │                     │     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  32. │                     │       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  33. │                     │         └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  34. │                     ├─base::withCallingHandlers(...)
#>  35. │                     ├─base::withVisible(value_fun(ev$value, ev$visible))
#>  36. │                     └─knitr (local) value_fun(ev$value, ev$visible)
#>  37. │                       └─knitr (local) fun(x, options = options)
#>  38. │                         ├─base::withVisible(knit_print(x, ...))
#>  39. │                         ├─knitr::knit_print(x, ...)
#>  40. │                         └─gganimate::knit_print.gganim(x, ...)
#>  41. │                           ├─base::do.call(animate, c(list(plot = x), knitr_options))
#>  42. │                           ├─gganimate (local) `<fn>`(...)
#>  43. │                           └─gganimate:::animate.gganim(...)
#>  44. │                             └─gganimate:::prerender(plot, nframes_total)
#>  45. │                               ├─ggplot2::ggplot_build(plot)
#>  46. │                               └─gganimate:::ggplot_build.gganim(plot)
#>  47. │                                 └─scene$after_defaults(data)
#>  48. │                                   └─gganimate (local) after_defaults(..., self = self)
#>  49. │                                     └─self$transition$expand_data(...)
#>  50. │                                       └─gganimate (local) expand_data(..., self = self)
#>  51. │                                         └─base::Map(...)
#>  52. │                                           └─base::mapply(FUN = f, ..., SIMPLIFY = FALSE)
#>  53. │                                             └─gganimate (local) `<fn>`(...)
#>  54. │                                               └─self$expand_layer(...)
#>  55. │                                                 └─gganimate (local) expand_layer(..., self = self)
#>  56. │                                                   └─tweenr::tween_state(...)
#>  57. │                                                     └─tweenr::.complete_states(from, to, id, enter, exit, .max_id(.data))
#>  58. │                                                       └─vctrs::vec_rbind(from, enters)
#>  59. └─vctrs (local) `<fn>`()
#>  60.   └─vctrs::vec_default_ptype2(...)
#>  61.     ├─base::withRestarts(...)
#>  62.     │ └─base (local) withOneRestart(expr, restarts[[1L]])
#>  63.     │   └─base (local) doWithOneRestart(return(expr), restart)
#>  64.     └─vctrs::stop_incompatible_type(...)
#>  65.       └─vctrs:::stop_incompatible(...)
#>  66.         └─vctrs:::stop_vctrs(...)
#>  67.           └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)

Created on 2023-10-18 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.0 (2023-04-21)
#>  os       macOS Big Sur 11.7.4
#>  system   x86_64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       America/New_York
#>  date     2023-10-18
#>  pandoc   3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version  date (UTC) lib source
#>  cli           3.6.1    2023-03-23 [1] CRAN (R 4.3.0)
#>  colorspace    2.1-0    2023-01-23 [1] CRAN (R 4.3.0)
#>  crayon        1.5.2    2022-09-29 [1] CRAN (R 4.3.0)
#>  digest        0.6.33   2023-07-07 [1] CRAN (R 4.3.0)
#>  dplyr         1.1.3    2023-09-03 [1] CRAN (R 4.3.0)
#>  evaluate      0.22     2023-09-29 [1] CRAN (R 4.3.0)
#>  fansi         1.0.4    2023-01-22 [1] CRAN (R 4.3.0)
#>  farver        2.1.1    2022-07-06 [1] CRAN (R 4.3.0)
#>  fastmap       1.1.1    2023-02-24 [1] CRAN (R 4.3.0)
#>  fs            1.6.3    2023-07-20 [1] CRAN (R 4.3.0)
#>  generics      0.1.3    2022-07-05 [1] CRAN (R 4.3.0)
#>  gganimate   * 1.0.8    2022-09-08 [1] CRAN (R 4.3.0)
#>  ggplot2     * 3.4.3    2023-08-14 [1] CRAN (R 4.3.0)
#>  gifski        1.12.0-2 2023-08-12 [1] CRAN (R 4.3.0)
#>  glue          1.6.2    2022-02-24 [1] CRAN (R 4.3.0)
#>  gtable        0.3.4    2023-08-21 [1] CRAN (R 4.3.0)
#>  hms           1.1.3    2023-03-21 [1] CRAN (R 4.3.0)
#>  htmltools     0.5.6    2023-08-10 [1] CRAN (R 4.3.0)
#>  knitr         1.44     2023-09-11 [1] CRAN (R 4.3.0)
#>  labeling      0.4.3    2023-08-29 [1] CRAN (R 4.3.0)
#>  lattice       0.21-9   2023-10-01 [1] CRAN (R 4.3.0)
#>  lifecycle     1.0.3    2022-10-07 [1] CRAN (R 4.3.0)
#>  magrittr      2.0.3    2022-03-30 [1] CRAN (R 4.3.0)
#>  Matrix        1.6-1.1  2023-09-18 [1] CRAN (R 4.3.0)
#>  mgcv          1.9-0    2023-07-11 [1] CRAN (R 4.3.0)
#>  munsell       0.5.0    2018-06-12 [1] CRAN (R 4.3.0)
#>  nlme          3.1-163  2023-08-09 [1] CRAN (R 4.3.0)
#>  pillar        1.9.0    2023-03-22 [1] CRAN (R 4.3.0)
#>  pkgconfig     2.0.3    2019-09-22 [1] CRAN (R 4.3.0)
#>  prettyunits   1.2.0    2023-09-24 [1] CRAN (R 4.3.0)
#>  progress      1.2.2    2019-05-16 [1] CRAN (R 4.3.0)
#>  R6            2.5.1    2021-08-19 [1] CRAN (R 4.3.0)
#>  reprex        2.0.2    2022-08-17 [1] CRAN (R 4.3.0)
#>  rlang         1.1.1    2023-04-28 [1] CRAN (R 4.3.0)
#>  rmarkdown     2.25     2023-09-18 [1] CRAN (R 4.3.0)
#>  rstudioapi    0.15.0   2023-07-07 [1] CRAN (R 4.3.0)
#>  scales        1.2.1    2022-08-20 [1] CRAN (R 4.3.0)
#>  sessioninfo   1.2.2    2021-12-06 [1] CRAN (R 4.3.0)
#>  stringi       1.7.12   2023-01-11 [1] CRAN (R 4.3.0)
#>  tibble        3.2.1    2023-03-20 [1] CRAN (R 4.3.0)
#>  tidyselect    1.2.0    2022-10-10 [1] CRAN (R 4.3.0)
#>  tweenr        2.0.2    2022-09-06 [1] CRAN (R 4.3.0)
#>  utf8          1.2.3    2023-01-31 [1] CRAN (R 4.3.0)
#>  vctrs         0.6.3    2023-06-14 [1] CRAN (R 4.3.0)
#>  withr         2.5.1    2023-09-26 [1] CRAN (R 4.3.0)
#>  xfun          0.40     2023-08-09 [1] CRAN (R 4.3.0)
#>  yaml          2.3.7    2023-01-23 [1] CRAN (R 4.3.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@jtlandis
Copy link
Author

After more investigating it seems that it may be linked to color/fill aesthetics, so enter/exit_recolor() are affected as well. My guess is when you use a geom that does not natively use fill like geom_point(), you get this error.

@jtlandis
Copy link
Author

Update

Doing something like to following will fix the issue:

ggplot(mtcars, aes(mpg, disp)) +
    geom_point(fill = "black") +
    geom_smooth(colour = 'grey', se = FALSE) +
    geom_smooth(aes(colour = factor(gear))) +
    transition_layers(layer_length = 1, transition_length = 2,
                      from_blank = FALSE) +
    enter_fade() + enter_grow()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant