Skip to content

Commit 6daf79c

Browse files
author
Stephanie Kirmer
committed
Tuning
1 parent 4d3031f commit 6daf79c

File tree

2 files changed

+66
-132
lines changed

2 files changed

+66
-132
lines changed

ioslides_deck_dc.Rmd

Lines changed: 21 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Animating Plots in R"
3-
subtitle: "DC R Conference"
3+
subtitle: "DC R 2019"
44
author: "Stephanie Kirmer <BR> [www.stephaniekirmer.com](http://www.stephaniekirmer.com) <BR> @[data_stephanie](http://www.twitter.com/data_stephanie)"
55
date: "November 8, 2019"
66
output:
@@ -38,7 +38,7 @@ Introductions, get the about-me out of the way and give a quick overview
3838
- I have four or more meaningful data dimensions
3939
- I want to display many levels of a single dimension
4040

41-
Also: If you need to see all the data points at the same time DON'T use animation
41+
Also: If you need to see all the data points at the same time, don't use animation
4242

4343
<div class="notes">
4444
Balance between encouragement and caution
@@ -118,7 +118,7 @@ Show these examples in realtime - tell people to google for more to get ideas
118118
It can be hard to imagine your data in an animation, so looking at examples of how other people do it can be v helpful
119119
</div>
120120

121-
## How to Think About the Design
121+
## Think About the Design
122122

123123
- What information do you want the audience to take away?
124124
- Movement leads the viewer to interpretation of the data - this can be good or bad
@@ -178,7 +178,7 @@ Option: look back at the examples from earlier and talk about what the states ar
178178

179179
# Building the Viz
180180

181-
## Project Overview
181+
## Example Project
182182

183183
Using data on displaced persons living in South Africa, show patterns and trends in refugee movement over twenty-plus years.
184184

@@ -188,8 +188,6 @@ Using data on displaced persons living in South Africa, show patterns and trends
188188
2. Over time, are the most common countries of origin about the same?
189189
3. Is the number of refugees coming from the most common countries of origin stable?
190190

191-
Follow along with the notebook: https://github.com/skirmer/animating_dataviz/blob/master/ioslides_deck.Rmd
192-
193191
Data Source: UNHCR via data.world: [UNHCR's populations of concern residing in South Africa](https://data.world/unhcr/244d728f-06e6-4c25-8eed-69e8fe3bffe0)
194192

195193
<div class="notes">
@@ -261,9 +259,9 @@ baseplot1
261259
![Let's make this!](final_race_plot2.gif)
262260

263261

264-
## Adjustments
262+
## Reformat the Plot
265263

266-
Flip axis, stop grouping bars, change to country as group
264+
Flip axis, change axes and margins, change grouping, etc.
267265

268266
```{r}
269267
baseplot3 <- ggplot(plotDT,
@@ -274,35 +272,18 @@ baseplot3 <- ggplot(plotDT,
274272
color = as.factor(X_country_origin)))+
275273
### </b>
276274
theme_bw()+
277-
theme(legend.position = "bottom")+
278-
geom_text(aes(y = 0, label = paste(X_country_origin, " ")), vjust = 0.2, hjust = 1) +
279-
coord_flip(clip = "off", expand = FALSE, ylim = c(0, 50000)) +
280-
### <b>
281-
geom_bar(aes(y = X_affected), stat = "identity", position = "identity")
282-
### </b>
283-
```
284-
285-
## New Visual
286-
287-
```{r, echo=FALSE, fig.width = 10}
288-
baseplot3
289-
```
290-
291-
292-
## Style Stuff
293-
294-
Adjust margins, fix axis text, drop legend, prettify Y, reverse X direction
295-
296-
If your stub has a `theme()` segment, applying a new one will overrule it.
297-
```{r}
298-
baseplot3 <- baseplot3 +
299275
### <b>
300276
theme(legend.position = "none",
301277
axis.ticks.y = element_blank(),
302278
axis.text.y = element_blank(),
303279
axis.title.y = element_blank(),
304280
plot.margin = margin(1,1,1,5, "cm"))+
305-
scale_y_continuous(labels = scales::comma) +
281+
### </b>
282+
geom_text(aes(y = 0, label = paste(X_country_origin, " ")), vjust = 0.2, hjust = 1) +
283+
coord_flip(clip = "off", expand = FALSE, ylim = c(0, 50000)) +
284+
### <b>
285+
geom_bar(aes(y = X_affected), stat = "identity", position = "identity")+
286+
scale_y_continuous(labels = scales::comma) +
306287
scale_x_reverse()
307288
### </b>
308289
@@ -372,7 +353,7 @@ It's nice, but we can do better
372353

373354
</div>
374355

375-
## Add Dynamic Labels
356+
## Improvements
376357

377358
Solving Problem 1 and 2: Added a descriptive title/label that indicate the year of the frame, label bars
378359

@@ -402,7 +383,7 @@ animate(animp, fps = 10, duration = 20)
402383

403384
Solving Problem 3: how do we want the animation elements to move?
404385

405-
Option: shrink and grow on exit and enter
386+
Choose exit and enter styles: grow and shrink?
406387

407388
```{r}
408389
@@ -434,9 +415,9 @@ animate(animp, fps = 10, duration = 20)
434415

435416
## Transition Options: Easing
436417

437-
Solving Problem 3: how do we want the animation elements to move?
438-
439-
Option: Ease between positions (moving on page, not exiting or entering)
418+
Choose easing: movement between positions (moving on page, not exiting or entering)
419+
Makes the transition speed change as it moves (functions may be cubic, quartic, etc)
420+
Here we see `quartic-in-out`
440421

441422
```{r}
442423
@@ -454,23 +435,19 @@ animp <- baseplot3 +
454435
```
455436

456437

457-
## Easing Transitions - Render
458-
459-
Makes the transition speed change as it moves (functions may be cubic, quartic, etc)
438+
## Quartic Easing
460439

461440
```{r, fig.width = 10, fig.height=6, echo = FALSE, cache = TRUE}
462441
463442
animate(animp, fps = 10, duration = 20)
464443
465444
```
466445

467-
## Transition Options: More Energetic
468-
469-
Solving Problem 3: how do we want the animation elements to move?
446+
## Bouncy Easing
470447

471-
Option: For fun, let's try "back" to see a springier approach
448+
Easing `back-in-out`: Feels a little cartoony- interesting, but again perhaps not what we need
472449

473-
```{r}
450+
```{r, fig.width = 10, fig.height=6, echo = FALSE, cache = TRUE}
474451
475452
animp <- baseplot3 +
476453
geom_text(aes(y = X_affected,
@@ -482,23 +459,13 @@ animp <- baseplot3 +
482459
### <b>
483460
ease_aes('back-in-out')
484461
### </b>
485-
```
486-
487-
488-
## Bouncy Transitions - Render
489-
490-
Feels a little cartoony- interesting, but again perhaps not what we need
491-
492-
```{r, fig.width = 10, fig.height=6, echo = FALSE, cache = TRUE}
493462
494463
animate(animp, fps = 10, duration = 20)
495464
496465
```
497466

498467
## Transition Options: Timing
499468

500-
Solving Problem 3: how do we want the animation elements to move?
501-
502469
In addition to entry, exit, and transition easing:
503470

504471
- Set pace for the states/transitions

ioslides_deck_dc.html

Lines changed: 45 additions & 78 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)