Skip to content

Plots in for loop #237

@cderv

Description

@cderv

Opening this issue to follow up on knitr report:

and as a way to keep track of this example. However, possibly related to

Plots in for loop are not treated the same as plots outside of it.

  • Only last is in output
res <- evaluate::evaluate(function(){ 
    library(tinyplot)
    for (thm in c("dark", "minimal")) {
        tinytheme(thm)
        tinyplot(I(Sepal.Length * 1e4) ~ Petal.Length | Species, data = iris)
    }
})
str(res, 1)
#> List of 3
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 2
#>   ..- attr(*, "engineVersion")= int 16
#>   ..- attr(*, "pid")= int 49608
#>   ..- attr(*, "Rversion")=Classes 'R_system_version', 'package_version', 'numeric_version'  hidden list of 1
#>   ..- attr(*, "load")= chr(0) 
#>   ..- attr(*, "attach")= chr(0) 
#>   ..- attr(*, "class")= chr "recordedplot"
#>  - attr(*, "class")= chr [1:2] "evaluate_evaluation" "list"
  • Both plots are recorded
res <- evaluate::evaluate(function(){ 
    library(tinyplot)
    tinytheme("dark")
    tinyplot(I(Sepal.Length * 1e4) ~ Petal.Length | Species, data = iris)
    tinytheme("minimal")
    tinyplot(I(Sepal.Length * 1e4) ~ Petal.Length | Species, data = iris)
})
str(res, 1)
#> List of 7
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 2
#>   ..- attr(*, "engineVersion")= int 16
#>   ..- attr(*, "pid")= int 71848
#>   ..- attr(*, "Rversion")=Classes 'R_system_version', 'package_version', 'numeric_version'  hidden list of 1
#>   ..- attr(*, "load")= chr(0) 
#>   ..- attr(*, "attach")= chr(0) 
#>   ..- attr(*, "class")= chr "recordedplot"
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 1
#>   ..- attr(*, "class")= chr "source"
#>  $ :List of 2
#>   ..- attr(*, "engineVersion")= int 16
#>   ..- attr(*, "pid")= int 71848
#>   ..- attr(*, "Rversion")=Classes 'R_system_version', 'package_version', 'numeric_version'  hidden list of 1
#>   ..- attr(*, "load")= chr(0) 
#>   ..- attr(*, "attach")= chr(0) 
#>   ..- attr(*, "class")= chr "recordedplot"
#>  - attr(*, "class")= chr [1:2] "evaluate_evaluation" "list"

Not sure if something can be done around that, but this is now definitely a differentiating approach with how litedown::fuse() handles plot. So I would like to dig into this.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions