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

unused arguments with svg device when knitting #484

Closed
cderv opened this issue Aug 29, 2023 · 0 comments
Closed

unused arguments with svg device when knitting #484

cderv opened this issue Aug 29, 2023 · 0 comments
Labels

Comments

@cderv
Copy link

cderv commented Aug 29, 2023

First reported at quarto-dev/quarto-cli#6643

---
title: "Label shouldn't be named"
output: 
  html_document:
    dev: svg
---

```{r}
library(gganimate)
```

```{r}
ggplot(mtcars, aes(factor(cyl), mpg)) + 
  geom_boxplot() + 
  transition_states(gear)
```
Quitting from lines 13-16 [unnamed-chunk-2] (test.Rmd)
                                                                                                            
Error in `device()`:
! arguments inutilisés (units = "in", res = 192)
Backtrace:
  1. rmarkdown::render(...)
  2. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  3. knitr:::process_file(text, output)
  7. knitr:::process_group.block(group)
  8. knitr:::call_block(x)
     ...
 19. knitr (local) value_fun(ev$value, ev$visible)
 20. knitr (local) fun(x, options = options)
 23. gganimate::knit_print.gganim(x, ...)
 26. gganimate:::animate.gganim(...)
 28. gganimate (local) `<fn>`(...)
Exécution arrêtée

We see error comes from gganimate itself. Especially here:

gganimate/R/animate.R

Lines 305 to 306 in 7cd46dc

for (i in seq_along(frames)) {
if (!stream) device(files[i], ...)

Basically some options are passed to svg() device function and they are not argument of grDevices::svg()

  • gganimate does define a knit_print method : https://github.com/thomasp85/gganimate/blob/7cd46dc2bc8cf18c1c81f6ef7fc4d00a1d57a385/R/gganim.R#L36C1-L37
  • It will defined some options among which units and res when no width or height; Both units and res are in error message

    gganimate/R/gganim.R

    Lines 46 to 54 in 7cd46dc

    get_knitr_options <- function(options, unlist = TRUE) {
    opt <- options$gganimate
    opt$device <- opt$device %||% options$dev
    if (is.null(opt$width) || is.null(opt$height)) {
    opt$width <- options$fig.width
    opt$height <- options$fig.height
    opt$units <- 'in'
    opt$res <- options$dpi
    }
  • Those options will be passed up to the device used selected in draw_frames

    gganimate/R/animate.R

    Lines 285 to 296 in 7cd46dc

    device <- switch(
    device,
    ragg_png = ragg::agg_png,
    png = png,
    jpg = ,
    jpeg = jpeg,
    tif = ,
    tiff = tiff,
    bmp = bmp,
    svg = svg,
    svglite = svglite::svglite
    )

res and in are not among svg() arguments

rlang::fn_fmls_names(grDevices::svg)
#> [1] "filename"     "width"        "height"       "pointsize"    "onefile"     
#> [6] "family"       "bg"           "antialias"    "symbolfamily"

Hence the error I believe.

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

No branches or pull requests

2 participants