Skip to main content
Animating slides

How to add animations to your slides in the course editor

Amy Peterson avatar
Written by Amy Peterson
Updated over 4 years ago

Once you've created a slide and added some content to it, you may want to add some simple animations to control the order in which items appear. The order that the animation appears depends on the number specified in the two sets of curly braces. In the example shown, we bring the code in first, and then the plot in second. We can also reverse this to bring the code in second, and the plot in first.

Another example you may encounter is if you'd like multiple slide elements to appear together at the same time. For example, let's say you'd like an image and code chunk to come in together, then another image and code chunk to come in together after that. You can do something like this:

Part 1:

![mtcars-scatterplot-formula.png](http://assets.datacamp.com/production/repositories/3930/datasets/d5ee1ee5041689dc8cd85ab5a76bef1828ae655a/mtcars-scatterplot-formula.png){{1}}

```r
plot(mtcars$hp, mtcars$mpg)
```{{1}}

Part 2:

![mtcars-scatterplot.png](http://assets.datacamp.com/production/repositories/3930/datasets/595b1e3003d9a20aa9919c92d659042f3bc289c8/mtcars-scatterplot.png){{2}}

```r
plot(mpg ~ hp, data = mtcars)
```{{2}}

Both elements in part 1 would appear together, followed by both elements in part 2.

Did this answer your question?