4

I try to make a dynamic presentation with knitr and animation. I pick the hook_r2swf which is the only one works on my machine.

For example, I knit the following .Rmd files:

# Test Animation

```{r, fig.show='animate', aniopts='autoresume'}
opts_knit$set(animation.fun = hook_r2swf)
plot(1,1,type="n")
plot(2,2,type='n')
```

However, it seems that the .swf will overlap all figures plotted in the chunk which may look like this:

<p><embed width="504" height="504" name="plugin" src="https://dl.dropbox.com/u/11900271/unnamed-chunk-1.swf" type="application/x-shockwave-flash"></p>

Does anyone know how to make the result non-overlapping?

I am using ubuntu 12.04 with following session info:

R version 2.15.3 (2013-03-01) Platform: i686-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=C                 LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] testpkg_1.0    xts_0.9-1      zoo_1.7-9      Rcpp_0.10.2    roxygen2_2.2.2 digest_0.5.2  
[7] knitr_1.1     

loaded via a namespace (and not attached):
[1] brew_1.0-6      evaluate_0.4.3  formatR_0.6     grid_2.15.3     lattice_0.20-13 stringr_0.6.2  
[7] tools_2.15.3   

Thanks!

wush978
  • 3,114
  • 2
  • 19
  • 23

1 Answers1

3

This seems to be an issue in the way animation is handled. The two plots are placed on top of each other. While I am not sure exactly how to prevent that itself, I can suggest the following workaround. By default, the background is transparent. If we change the background to white, the problem is solved:

```{r, fig.show='animate'}
opts_knit$set(animation.fun = hook_r2swf)
par(bg="white")
plot(1,1,type="n")
plot(2,2,type='n')
```
sebastian-c
  • 15,057
  • 3
  • 47
  • 93