animint - an R package for animated interactive web graphics
Animint makes it possible to design multi-layer, multi-plot, interactive, and possibly animated data visualizations using just a few lines of R code. Animint adds clickSelects and showSelected aesthetics to ggplot2, and renders using D3. For example, this multi-layer facetted interactive animation of WorldBank data was defined using only about 60 lines of R code.
Installation
if (!require(devtools)) install.packages("devtools")
devtools::install_github("tdhock/animint", upgrade_dependencies=FALSE)
library(animint)
example(animint)NOTE: animint now works with standard ggplot2 >= 2.0 thanks to Faizan and Kevin! If you want to use the animint chunk_vars option then you will need to install hadley/ggplot2#1649 (it permits non-standard geom options).
Learning animint through examples
The best way to learn animint is through examples. A couple of good introductions are Carson Sievert's Interactive animations of PITCHf/x and Susan VanderPlas' animint tutorial. In addition, there is an examples web site, examples distributed with animint, as well as more complex 'big data' examples in the tdhock/animint-examples repo.
Frequently asked questions (FAQ)
Is there a list of new features in Animint, with respect to standard ggplot2? Yes.
Can I do brushing in Animint? If by "brushing" you mean "multiple selection," then yes the designer can use the selector.types option to declare a multiple selection variable, which means that users will be able to click plot elements to add/remove items from the multiple selection set. For example see the WorldBank-facets viz and source code.
Can I use animint inside of a Shiny app? Yes.
Can I use animint inside of knitr? Yes, but use
structure(viz, class="animint")rather thananimint2dir(viz)Can I use animint inside of an interactive Rmarkdown document? Yes (source).
Contribute to animint!
Write tests to increase code coverage
The easiest way to contribute to animint is by writing a new test that would increase the code coverage. First check the coveralls status page and find a part of the code which is not tested. Then fork animint and commit a new test that increases the coverage, and send us a Pull Request. It may be useful to read about our testing framework.
Learn about the design and theory of animint
Before adding features to animint, you should first read about its design. There are two main components, which have separate wiki pages that explain their details:
It would also be useful to read some theory in the academic paper describing Animint. It explains:
- the purpose of animint: make it easy to design data visualizations
which can be both animated and interactive.
- the clickSelects and showSelected keywords which permit
interactive linked plots.
- the advantages and disadvantages of animint compared to other
interactive data viz libraries.
It may also be useful to read our short and long tables of related work.
TODO list of features to implement
We keep a TODO list at top of the NEWS file. Feel free to implement one and send us a PR. They are categorized as follows:
- BUG: things which used to work but have stopped working. Tests should be added to prevent these. For example at one point in 2013, animint rendered the correct number of legend entries for the WorldBank viz, but in the beginning of 2014 animint rendered too many legend entries.
- GGPLOT: things which ggplot2 supports but animint does not yet support. For example facets, coord_equal.
- DSL: changes to the animint domain-specific language (DSL) which would allow interactive/animated features. These involve changes to how we define the ggplots, and how the compiler works. For example custom alpha/color/etc for selected geoms, using selected.alpha/selected.color/etc aesthetics.
- EXAMPLE: examples to show off animint features, which should affect neither the compiler nor renderer.
- RENDER: changes to the JavaScript rendering code which would result in better interactive plots, without having to change the definition of the ggplots. For example rendering a selection widget for every selection variable.
- OUTPUT: different output formats for viewing/sharing an interactive animation.
- OPTIMIZATION: things which are currently supported, but with an implementation that could be improved in terms of render/compile speed, disk usage, memory, etc. Typically these optimizations are not really noticed for small data sets, but make it easier to visualize large data sets. For example, can we gzip the TSV plot data files to reduce disk space and download times?