Learn R Programming

gganimate (version 1.0.9)

shadow_mark: Show original data as background marks

Description

This shadow lets you show the raw data behind the current frame. Both past and/or future raw data can be shown and styled as you want.

Usage

shadow_mark(past = TRUE, future = FALSE, ..., exclude_layer = NULL)

Arguments

past

Should raw data from earlier in the animation be shown

future

Should raw data from later in the animation be shown

...

changes to the shadow data, e.g. alpha = alpha/2 or colour = 'grey'

exclude_layer

Indexes of layers that should be excluded.

See Also

Other shadows: shadow_null(), shadow_trail(), shadow_wake()

Examples

Run this code
# Use any of the aesthetics to add a style to either the past or the future raw data.
# Adding a grouping variable in a transition call prior to calling `shadow_mark()` will
# allow transitioning through different states in time.

p1 <- ggplot(airquality, aes(Day, Temp)) +
  geom_line(color = 'red', size = 1) +
  transition_time(Month) +
  shadow_mark(colour = 'black', size = 0.75)

# animate(p1)

# Add a future = TRUE argument to show data later in the animation.

p2 <- ggplot(airquality, aes(Day, Temp)) +
  geom_line(color = 'red', size = 1) +
  transition_time(Month) +
  shadow_mark(color = 'black', size = 0.75, past = FALSE, future = TRUE)

# animate(p2)

Run the code above in your browser using DataLab