## Plot individual example trajectories
# Time-normalize trajectories
mt_example <- mt_time_normalize(mt_example)
# Plot all time-normalized trajectories
# varying the color depending on the condition
mt_plot(mt_example, use="tn_trajectories",
color="Condition")
# ... setting alpha < 1 for semi-transparency
mt_plot(mt_example, use="tn_trajectories",
color="Condition", alpha=.2)
# ... with custom colors
mt_plot(mt_example, use="tn_trajectories",
color="Condition") +
ggplot2::scale_color_brewer(type="qual")
# Create separate plots per Condition
mt_plot(mt_example, use="tn_trajectories",
facet_col="Condition")
# Create customized plot by setting the return_type option to "mapping"
# to setup an empty plot. In a next step, a geom is added.
# In this example, only points are plotted.
mt_plot(mt_example, use="tn_trajectories",
color="Condition", return_type="mapping") +
ggplot2::geom_point()
# Plot velocity profiles based on the averaged trajectories
# varying the color depending on the condition
mt_example <- mt_derivatives(mt_example)
mt_example <- mt_average(mt_example, interval_size=100)
mt_plot(mt_example, use="av_trajectories",
x="timestamps", y="vel", color="Condition")
## Plot aggregate trajectories for KH2017 data
# Time-normalize trajectories
KH2017 <- mt_time_normalize(KH2017)
# Plot aggregated time-normalized trajectories per condition
mt_plot_aggregate(KH2017, use="tn_trajectories",
color="Condition")
# ... first aggregating trajectories within subjects
mt_plot_aggregate(KH2017, use="tn_trajectories",
color="Condition", subject_id="subject_nr")
# ... adding points for each position to the plot
mt_plot_aggregate(KH2017, use="tn_trajectories",
color="Condition", points=TRUE)
if (FALSE) {
# Create combined plot of individual and aggregate trajectories
# by first plotting the individual trajectories using mt_plot.
# In a next step, the aggregate trajectories are added using the
# mt_plot_aggregate function with the return_type argument set to "geom".
mt_plot(KH2017, use="tn_trajectories", color="Condition", alpha=.05) +
mt_plot_aggregate(KH2017, use="tn_trajectories",
color="Condition", return_type="geom", size=2)
}
Run the code above in your browser using DataLab