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.
shadow_mark(past = TRUE, future = FALSE, ..., exclude_layer = NULL)
Should raw data from earlier in the animation be shown
Should raw data from later in the animation be shown
changes to the shadow data, e.g. alpha = alpha/2
or
colour = 'grey'
Indexes of layers that should be excluded.
Other shadows:
shadow_null()
,
shadow_trail()
,
shadow_wake()
# 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)
#> Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` instead.
# 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)