Polishing animations

Intermediate Interactive Data Visualization with plotly in R

Adam Loy

Statistician, Carleton College

Customizations

Animation options

  • Time between frames
  • Frame transitions
  • Slider appearance

Plotting options

  • Glyph color, shape, size
  • Axis labels, transformations
  • Tools tips (e.g. hover text)
Intermediate Interactive Data Visualization with plotly in R

Animation options

Basic animation with default settings.

ani <- world_indicators %>%
  plot_ly(x = ~income, y = ~co2) %>%
  add_markers(frame = ~year, 
              ids = ~country, 
              showlegend = FALSE) %>%
  layout(xaxis = list(type = "log"),
         yaxis = list(type = "log"))
Intermediate Interactive Data Visualization with plotly in R

Animation options

Basic animation with default settings.

ani %>%
  animation_opts(
      frame = 500, 
      transition = frame,
      easing = "linear",
      redraw = TRUE
   )
Intermediate Interactive Data Visualization with plotly in R

Speeding up

Sped up scatterplot animation using frame = 300.

ani %>%
  animation_opts(frame = 300)
Intermediate Interactive Data Visualization with plotly in R

Pausing between frames

Animation with 350 millisecond pause on each frame.

ani %>%
  animation_opts(
     frame = 700, 
     transition = 350
  )
Intermediate Interactive Data Visualization with plotly in R

Bouncing points

Animation using easing = "bounce".

ani %>%
  animation_opts(easing = "bounce")

Basic easing options:

"linear", "quad", "cubic", "sin", "exp", "circle", "elastic", "back", "bounce"

Intermediate Interactive Data Visualization with plotly in R

Slider options

Basic animation with default settings.

ani
Intermediate Interactive Data Visualization with plotly in R

Removing the slider

Animation with no slider.

ani %>%
  animation_slider(hide = TRUE)
Intermediate Interactive Data Visualization with plotly in R

Editing slider text

Removing the prefix "year: " from the slider.

ani %>%
  animation_slider(
     currentvalue = list(prefix=NULL)
  )
Intermediate Interactive Data Visualization with plotly in R

Editing slider text

Increasing the slider text to 40 and changing the color to black.

ani %>%
  animation_slider(
     currentvalue = list(prefix=NULL,
        font = list(
           color = "black", 
           size = 40
        )
     )
  )
Intermediate Interactive Data Visualization with plotly in R

Let's practice!

Intermediate Interactive Data Visualization with plotly in R

Preparing Video For Download...