This view is a bit like view_follow()
but will not match the data in each
frame. Instead it will switch between being static and zoom to the range of
the data. It is a great pairing with transition_states()
as it can move the
view while the data is static and then be static while the data moves. The
standard version will look at the data present in the calculated frames and
set the ranges based on that, while the _manual
version will allow you to
define your own ranges.
view_step(
pause_length = 1,
step_length = 1,
nsteps = NULL,
look_ahead = pause_length,
delay = 0,
include = TRUE,
ease = "cubic-in-out",
wrap = TRUE,
pause_first = FALSE,
fixed_x = FALSE,
fixed_y = FALSE,
exclude_layer = NULL,
aspect_ratio = 1
)
view_step_manual(
pause_length = 1,
step_length = 1,
xmin,
xmax,
ymin,
ymax,
delay = 0,
ease = "cubic-in-out",
wrap = TRUE,
pause_first = FALSE,
fixed_x = FALSE,
fixed_y = FALSE,
exclude_layer = NULL,
aspect_ratio = 1
)
The relative length the view will be kept static. Will be recycled to match the number of steps
The relative length the view will use to transition to the new position. Will be recycled to match the number of steps
The number of steps. If NULL
it will be set to the max length
of pause_length
or step_length
A relative length to look ahead in the animation to get the new zoom area. Allow the view to zoom to where the data will be
A relative length to switch the view back and forth relative to the actual frames. E.g. if delay is calculated to 5 frames, frame 6 will get the view intended for frame 1.
Should the steps include both the start and end frame range
The easing function used for the step
As in transition_states()
. Should the view wrap around and zoom
back to the first state.
Should the view start with a pause. The default is to
start with a step so that it is aligned to the static period in
transition_states()
Either a logical indicating if the dimension should
not be modified by the view, or a numeric vector giving the lower and upper
bounds of the dimension. For the latter, an NA
value will be substituted
for whatever is calculated by the view (e.g. fixed_x = c(0, NA)
) will fix
the minimum x value to 0 and let the view calculate the upper bound.
Integer vector of layer indices that should be ignored when calculating the view
If the coord is fixed, ensure that the view matches the
given aspect ratio. Will override anything given in fixed_x
/fixed_y
Vectors of even length defining the boundaries of the different views to go through
Other views:
view_follow()
,
view_static()
,
view_zoom()
anim <- ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1) +
view_step(pause_length = 2, step_length = 1, nsteps = 3)
# Default is to include the data from the two states you're stepping between
# but this can be turned off
anim <- ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1) +
view_step(pause_length = 2, step_length = 1, nsteps = 3, include = FALSE)
# Default is to work off-beat of transition_states so that view changes while
# data is static. Setting pause_first=TRUE changes this
anim <- ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1) +
view_step(pause_length = 1, step_length = 2, nsteps = 3, pause_first = TRUE)
# If the transition doesn't wrap, then the view shouldn't either
anim <- ggplot(iris, aes(Petal.Length, Petal.Width)) +
geom_point() +
transition_states(Species, transition_length = 2, state_length = 1, wrap = FALSE) +
view_step(pause_length = 2, step_length = 1, nsteps = 3, wrap = FALSE)