# Load ggplot2
library(ggplot2)
# 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",
x="xpos", y="ypos", color="Condition")
# ... with custom colors
mt_plot(mt_example, use="tn_trajectories",
x="xpos", y="ypos", color="Condition") +
scale_color_brewer(type="qual")
# Plot aggregated time-normalized trajectories per condition
mt_plot_aggregate(mt_example, use="tn_trajectories",
x="xpos", y="ypos", color="Condition")
# ... first aggregating trajectories within subjects
mt_plot_aggregate(mt_example, use="tn_trajectories",
x="xpos", y="ypos", color="Condition",
subject_id="subject_nr")
# ... adding points for each position to the plot
mt_plot_aggregate(mt_example, use="tn_trajectories",
x="xpos", y="ypos", color="Condition")+
geom_point()
# Plot velocity profiles based on the averaged trajectories
# varying the color depending on the condition
mt_example <- mt_calculate_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")Run the code above in your browser using DataLab